39 lines
1.0 KiB
Java
39 lines
1.0 KiB
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class Galerie {
|
||
|
|
||
|
private static String[] paths = {
|
||
|
"house", "info", "ok", "mail", "whatsapp"
|
||
|
};
|
||
|
|
||
|
private static int count = -1;
|
||
|
private static JLabel lb;
|
||
|
private static JFrame window;
|
||
|
|
||
|
public static void update(boolean increment) {
|
||
|
count += increment ? 1 : -1;
|
||
|
if (count == -1) {
|
||
|
count = paths.length-1;
|
||
|
}
|
||
|
count %= paths.length;
|
||
|
|
||
|
if (lb != null) window.remove(lb);
|
||
|
|
||
|
String path = "./images/" + paths[count] + ".png";
|
||
|
lb = new JLabel(new ImageIcon(path));
|
||
|
lb.addMouseListener(new GalleryListener());
|
||
|
window.add(lb, BorderLayout.CENTER);
|
||
|
window.revalidate();
|
||
|
}
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
window = new JFrame("Galerie");
|
||
|
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
window.setSize(650, 650);
|
||
|
window.setLocation(200, 200);
|
||
|
window.setVisible(true);
|
||
|
|
||
|
Galerie.update(true);
|
||
|
}
|
||
|
}
|