Java Swing problem - image hides the buttons ?

mov2k6

New member
I am trying to create an application in Eclipse and I create the visual part using swing. I am also using absolute values for the form components. The idea is that i paint an image on the form an i want to put 2 buttons on the image. When I run the application the buttons won't show but when I place the cursor over them, they appear. I know that there is a problem regarding the way the paint(Graphics g) is called but cannot figure out what it is . Can you please help me ?

//this is my paint method; my buttons are contained in the this.getContentPane();
public void paint(Graphics g)
{
super.paint(g);

Container contentPane = this.getContentPane();

Graphics2D g2d = (Graphics2D)contentPane.getGraphics();

g2d.drawImage(ImageIO.read(new File("src\RaceTrack.png")),0,0,this);

}
 
Back
Top