import javax.swing.*; import java.awt.*; public class ImageTutorial extends JFrame { private ImageIcon image; private JLabel label; private ImageIcon mario; private JLabel mariolabel; private ImageIcon luige; private JLabel luigelabel; ImageTutorial() { setLayout(new GridBagLayout()); image = new ImageIcon(getClass().getResource("main/castle.png")); label = new JLabel(image); label.setHorizontalAlignment(JLabel.CENTER); mario = new ImageIcon(getClass().getResource("main/mario.jpg")); mariolabel = new JLabel(mario); label.add(mariolabel); luige = new ImageIcon(getClass().getResource("main/luige.jpg")); luigelabel = new JLabel(luige); label.add(luigelabel); add(label); pack(); setVisible(true); } public static void main(String [] args) { ImageTutorial gui = new ImageTutorial(); gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setVisible(true); gui.pack(); gui.setTitle("Mario vs Luige Quiz Board Game"); } }
How do I make it so that my luigelabel and mariolabel are infront of my label. Currently i can only see my label (background image) :S