I need to do a jet fighter game for my school project and I couldn't get how to put a plane image over a gif background. Here is what I try to do:
photo of what I am trying to do:
And here is the code I wrote so far:
public class GameScreen {
public GameScreen() {
JFrame frame=new JFrame();
JPanel panel=new JPanel();
frame.setSize(500, 550);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
panel.setLayout(null);
JLabel Background;
Background=new JLabel(new ImageIcon(getClass().getResource("/image/background.gif")));
Background.setBounds(0, 0, 500, 550);
panel.add(Background);
JLabel jet;
jet=new JLabel(new ImageIcon(getClass().getResource("/image/jet.png")));
jet.setBounds(400, 400, 50, 50);
panel.add(jet);
frame.setVisible(true);
}
}
When I run this, the jet image does not show, because I think it stays below the background. How can I solve this issue?