How to create an ArrayList with PImage

I am trying to optimize a sketch where instead of loading 200 images to an array, I am loading only 10 at a time that are cycled through, but keeps updating throughout the sketch so it goes through all the images. I have read elsewhere in the forum that a good way to do this is to use an ArrayList, but I am not sure how to create an ArrayList of images that calls up images from a folder.

I got as far as this:

String basedir = "/Users/admin/Desktop/Borderscape_OF/test"; 
String fileext = ".jpg";
ArrayList<PImage> imgList = new ArrayList<PImage>();


java.io.File folder = new java.io.File(dataPath(basedir));
java.io.FilenameFilter extfilter = new java.io.FilenameFilter() {
  boolean accept(File dir, String name) {
    return name.toLowerCase().endsWith(fileext);
  }
};

void setup() {
  fullScreen();
  frameRate(7);
  background(0);

  filenames = folder.list(extfilter);
  imgList = new ArrayList<PImage>();

  for (int h = 0; h < 10; h++) {
    imgList.add(new PImage());
}
}

But now I am stuck.

Answers

This discussion has been closed.