import javax.swing.*; import java.awt.*; public class Confirmation { private static String[] paths = { "house", "info", "ok", "mail", "whatsapp" }; private static CardLayout cards; private static Container contentPane; public static void next() { cards.next(contentPane); } public static void previous() { cards.previous(contentPane); } public static void main(String[] args) { JFrame window = new JFrame("GalerieAlt"); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setSize(700, 700); window.setLocation(200, 200); window.addWindowListener(new ConfirmationListener()); window.setVisible(true); contentPane = window.getContentPane(); cards = new CardLayout(); contentPane.setLayout(cards); for (String path : paths) { JLabel label = new JLabel(new ImageIcon("./images/" + path + ".png")); label.addMouseListener(new ConfirmationListener()); contentPane.add(label, path); } } }