Hi,
One approach is to place a JLabel within the content of the panel and then set the icon on the label...
Another approach, which I prefer, is to override the paintComponent method...This is best used for creating a background image for your panels...
public class ImagePnl extends JPanel
{
ImageIcon ic = new ImageIcon("montage.jpg");
public ImagePnl()
{
}
public void paintComponent(Graphics g)
{
g.drawImage(ic.getImage() ,0,0,Color.red, null);
}
}
I use imageIcon waits until the image is loaded, which would occur during construction...