This commit is contained in:
2025-09-26 11:16:47 +02:00
parent a9782efcdd
commit 7c72e94d8d
18 changed files with 174 additions and 36 deletions

View File

@@ -0,0 +1,55 @@
import java.io.File;
import java.awt.CardLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ImageWindow extends JFrame {
private CardLayout cards;
private JPanel imagePanel;
public ImageWindow() {
this.setSize(1024, 1024);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
File resourcesDirectory = new File("../resources/");
if(resourcesDirectory.exists() && resourcesDirectory.isDirectory()) {
File[] files = resourcesDirectory.listFiles();
if(files != null) {
this.cards = new CardLayout();
this.imagePanel = new JPanel();
this.imagePanel.setLayout(this.cards);
for(File file : files) {
JLabel label = new JLabel(new ImageIcon(file.getPath()));
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);
this.imagePanel.add(new JLabel(new ImageIcon(file.getPath())), file.getName());
}
this.add(this.imagePanel);
this.addMouseListener(new ClickSwapImageEvent(this));
this.addWindowListener(new WindowClosedEvent(this));
this.nextImage();
}
}
}
public void nextImage() {
this.cards.next(this.imagePanel);
}
public void lastImage() {
this.cards.previous(this.imagePanel);
}
}