some changes

This commit is contained in:
2025-10-02 10:48:05 +02:00
parent 8b6d447574
commit 6ceeffac0e
14 changed files with 342 additions and 48 deletions

View File

@@ -0,0 +1,49 @@
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];
}
}