APL/DEV 3.1/TP2/Galerie/GalerieAlt.java
2022-09-14 11:01:07 +02:00

38 lines
1.0 KiB
Java

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);
}
}
}