Create a pagination of images

Download javafx eBook

Example

ArrayList<String> images = new ArrayList<>();
images.add("some\\cool\\image");
images.add("some\\other\\cool\\image");
images.add("some\\cooler\\image");

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.

Stats

Contributors: 2
2016-08-04
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook