How to set a background image in a frame or in a panel in java?
I want to add a background image to my frame. I am using netbeans as my IDE, so please anyone can tell how to do that.
If you even know, how to add an image to a panel, that would also work out..
Remember, it must be a background image, so that I can add my other components too so don’t suggest label for it…
Thanks.
Override the public void paint(Graphics g) method in your Container, either JFrame or JPanel. Then use the Graphics reference passed to the method to draw the image you want using the drawImage() method of Graphics. The drawImage() method is overloaded: http://download.oracle.com/javase/7/docs/api/java/awt/Graphics.html