clean structure

This commit is contained in:
2026-02-10 18:05:13 +01:00
parent 5f2d805875
commit 4b4a0a3597
33 changed files with 0 additions and 0 deletions

View File

@@ -1,6 +0,0 @@
import java.util.AbstractQueue;
import java.util.Collection;
public class CustomQueue<E> extends AbstractQueue<E> {
}

View File

@@ -1,23 +0,0 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class ClickSwapImageEvent extends MouseAdapter {
private ImageWindow window;
public ClickSwapImageEvent(ImageWindow window) {
this.window = window;
}
public void mouseClicked(MouseEvent event) {
System.out.println(this.window.manager.cursor);
if(event.getX() > this.window.getWidth() / 2) {
this.window.nextImage();
System.out.println(this.window.manager.cursor);
return;
}
this.window.previousImage();
System.out.println(this.window.manager.cursor);
}
}

View File

@@ -1,49 +0,0 @@
import java.io.File;
import javax.swing.ImageIcon;
public class ImageManager {
private ImageIcon[] images;
public int cursor;
public ImageManager() {
File resourcesDirectory = new File("../resources/");
if(resourcesDirectory.exists() && resourcesDirectory.isDirectory()) {
File[] files = resourcesDirectory.listFiles();
if(files != null) {
this.images = new ImageIcon[files.length];
this.cursor = 0;
for(File file : files) {
this.images[this.cursor] = new ImageIcon(file.getPath());
this.cursor++;
}
this.cursor = 0;
}
}
}
public ImageIcon getNextImage() {
if(this.cursor >= this.images.length - 1) {
this.cursor = 0;
} else {
this.cursor++;
}
return this.images[this.cursor];
}
public ImageIcon getPreviousImage() {
if(this.cursor <= 0) {
this.cursor = this.images.length - 1;
} else {
this.cursor--;
}
return this.images[this.cursor];
}
}

View File

@@ -1,46 +0,0 @@
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ImageWindow extends JFrame {
public ImageManager manager;
private JLabel label;
public ImageWindow() {
this.manager = new ImageManager();
this.setSize(1024, 1024);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addMouseListener(new ClickSwapImageEvent(this));
this.nextImage();
}
public void nextImage() {
if(this.label != null) {
this.remove(this.label);
}
this.label = new JLabel(this.manager.getNextImage());
this.label.setVerticalAlignment(JLabel.CENTER);
this.label.setHorizontalAlignment(JLabel.CENTER);
this.add(label);
this.revalidate();
}
public void previousImage() {
if(this.label != null) {
this.remove(this.label);
}
this.label = new JLabel(this.manager.getPreviousImage());
this.label.setVerticalAlignment(JLabel.CENTER);
this.label.setHorizontalAlignment(JLabel.CENTER);
this.add(label);
this.revalidate();
}
}

View File

@@ -1,7 +0,0 @@
public class Main {
public static void main(String[] args) {
ImageWindow window = new ImageWindow();
window.setVisible(true);
}
}

View File

@@ -1,19 +0,0 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
public class ApprovedButtonPressedEvent implements ActionListener{
private JDialog dialog;
public ApprovedButtonPressedEvent(JDialog dialog) {
this.dialog = dialog;
}
@Override
public void actionPerformed(ActionEvent event) {
this.dialog.dispose();
this.dialog.getOwner().dispose();
}
}

View File

@@ -1,18 +0,0 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
public class CancelButtonPressedEvent implements ActionListener{
private JDialog dialog;
public CancelButtonPressedEvent(JDialog dialog) {
this.dialog = dialog;
}
@Override
public void actionPerformed(ActionEvent event) {
this.dialog.dispose();
}
}

View File

@@ -1,20 +0,0 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class ClickSwapImageEvent extends MouseAdapter {
private ImageWindow window;
public ClickSwapImageEvent(ImageWindow window) {
this.window = window;
}
public void mouseClicked(MouseEvent event) {
if(event.getX() > this.window.getWidth() / 2) {
this.window.nextImage();
return;
}
this.window.lastImage();
}
}

View File

@@ -1,37 +0,0 @@
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CloseVerificationWindow extends JDialog {
public CloseVerificationWindow(ImageWindow parent) {
super(parent, true);
this.setSize(parent.getWidth() / 3, parent.getHeight() / 3);
this.setLocationRelativeTo(parent);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setLayout(new GridLayout(2, 1));
JLabel text = new JLabel("Are you sure you want to close the window?");
text.setVerticalAlignment(JLabel.CENTER);
text.setHorizontalAlignment(JLabel.CENTER);
this.add(text);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
JButton approveButton = new JButton("Yes");
approveButton.addActionListener(new ApprovedButtonPressedEvent(this));
panel.add(approveButton, BorderLayout.WEST);
JButton cancelButton = new JButton("No");
cancelButton.addActionListener(new CancelButtonPressedEvent(this));
panel.add(cancelButton, BorderLayout.EAST);
this.add(panel);
}
}

View File

@@ -1,55 +0,0 @@
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);
}
}

View File

@@ -1,6 +0,0 @@
public class Main {
public static void main(String[] args) {
ImageWindow window = new ImageWindow();
window.setVisible(true);
}
}

View File

@@ -1,16 +0,0 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class WindowClosedEvent extends WindowAdapter {
private ImageWindow window;
public WindowClosedEvent(ImageWindow window) {
this.window = window;
}
@Override
public void windowClosing(WindowEvent event) {
(new CloseVerificationWindow(this.window)).setVisible(true);
}
}

View File

@@ -1,3 +0,0 @@
rm -rf *.class
javac Main.java
java Main

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB