import javax.swing.*; import java.awt.*; public class GalerieAlt { 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.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 GalleryAltListener()); contentPane.add(label, path); } } }