javafx Pagination Create a pagination of images


ArrayList<String> images = new ArrayList<>();

Pagination p = new Pagination(3);
p.setPageFactory(n -> new ImageView(images.get(n)));

Note that the paths must be urls, not filesystem paths.

How it works

p.setPageFactory(n -> new ImageView(images.get(n)));

Everything else is just fluff, this is where the real work is happening. setPageFactory takes a callback that takes an int, and returns the node that we want at that index. The first page maps to the first item in the list, the second to the second item in the list and so on.