I am trying to add a background image to a JPanel within a JFrame.
The supplied code below works fine to display the image.
However, when I add another component (JButton, or an additional JPanel) to the panel with the background it does not show through the background image(sometimes a JButton does but only when moused over). My question is, how do I add a background image that I can then add other components on top of?
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}

New Topic/Question
Reply




MultiQuote




|