Adding Background

I have made a stand-alone app using JPanel and want to add a Image (tiled), instead of color, as a background. Can someone help me pse.
[149 byte] By [cbrink] at [2007-9-26 7:27:06]
# 1
simply add the image to a JLabel and size this to the sizeu want it, and then add it first before other componentseg. getContentPane().add(JLabel);"" (all other components...hope this is clear...
naslund26 at 2007-7-1 17:21:44 > top of Java-index,Archived Forums,Swing...
# 2
How do I then add the other components on top of the background?
cbrink at 2007-7-1 17:21:44 > top of Java-index,Archived Forums,Swing...
# 3

create a custom JPanel, e.g.

public class BackgroundJPanel extends JPanel {

Image backImage;

public BackgroundJPanel() {

super();

//load the image

}

public void paint(Graphics g) {

//g.drawImage(image, ....)

//If you want to tile the image, repeat the image many times

}

}

Now, you can use this class instead of JPanel

ashutosh at 2007-7-1 17:21:44 > top of Java-index,Archived Forums,Swing...