clean structure
This commit is contained in:
46
DEV/DEV3.2/TP_Recursion/Part1/ImageWindow.java
Normal file
46
DEV/DEV3.2/TP_Recursion/Part1/ImageWindow.java
Normal file
@@ -0,0 +1,46 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user