public class main extends JFrame {
JPanel panel = new JPanel();
JButton playGame = new JButton("PLAY GAME");
public void paint(java.awt.Graphics g) {
super.paint(g);
BufferedImage image = null;
try {
image = ImageIO.read(new File("./src/Images/menu.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
g.drawImage(image, 0, 0, 1000, 600, this);
}
public main(){
super();
playGame.setBounds(390, 250, 220, 30);
//panel.setBounds(80, 800, 200, 100);
panel.setLayout(null);
panel.add(playGame);
add(panel);
setTitle("MENU");
setSize(1000,600);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
//setLayout(new FlowLayout());
setVisible(true);
}
public static void main(String[] args) {
new main();
}
}
I am trying to add my JButton
over the image but it is coming behind the image.
The problem is I don't know how to add a background picture so that the buttons appear at the top of the picture. Is there any for me set up a background picture so that the other panels show up on top as well?