I have been searching all over the sites, but i couldn't manage to get button or any other component on a image panel. There are some codes that says while painting the picture you can show components. Basically they are overriding the paint method of the panel. But i need to make my frame background image while not having the diffuculties of overriding the paint method of panel because i have many components . Netbeans offers me to change background color , but i need to change the background image, So, is there any concrete solution to that problem . Thanks in advance.
Painting components on Panel Picture ?/?
Collapse
X
-
Override paintComponent( ) in the panel to draw the background. This has nothing to do with whether you have child components or how many you have. Basically you have to paint the background somewhere, and paintComponent( ) is the place.
See A closer look at the painting mechanism in Sun's Tutorial. (The Tutorial, by the way, is a better source of factually accurate material than "some codes" on teh internet, or random responses - including this one - from forums.)
As far as the child components are concerned, just add them. They get painted along with the background as explained in the link above.
[Edit] I have no clue about how this is done in NB. It's (yet another) case of the GUI builder facilitating the use, but obscuring the understanding of the technology. Perhaps you could put the IDE aside for a bit.
Comment