Class Pagination

java.lang.Object
All Implemented Interfaces:
Styleable, EventTarget, Skinnable

@DefaultProperty("pages") public class Pagination extends Control

A Pagination control is used for navigation between pages of a single content, which has been divided into smaller parts.

Styling the page indicators

The control can be customized to display numeric page indicators or bullet style indicators by setting the style class STYLE_CLASS_BULLET. The maxPageIndicatorCountProperty can be used to change the maximum number of page indicators. The property value can also be changed via CSS using -fx-max-page-indicator-count. By default, page indicator numbering starts from 1 (corresponding to page index 0).

Page count

The pageCountProperty controls the number of pages this pagination control has. If the page count is not known, INDETERMINATE should be used as the page count.

Page factory

The pageFactoryProperty is a callback function that is called when a page has been selected by the application or the user. The function is required for the functionality of the pagination control. The callback function should load and return the contents of the selected page. null should be returned if the selected page index does not exist.

Creating a Pagination control:

A simple example of how to create a pagination control with ten pages and each page containing text.

 Pagination pagination = new Pagination(10, 0);
 pagination.setPageFactory(new Callback<Integer, Node>() {
     @Override
     public Node call(Integer pageIndex) {
         return new Label(pageIndex + 1 + ". Lorem ipsum dolor sit amet,\n"
                      + "consectetur adipiscing elit,\n"
                      + "sed do eiusmod tempor incididunt ut\n"
                      + "labore et dolore magna aliqua.");
     }
 });
or using lambdas
 Pagination pagination = new Pagination(10, 0);
 pagination.setPageFactory(pageIndex ->
         new Label(pageIndex + 1 + ". Lorem ipsum dolor sit amet,\n"
                      + "consectetur adipiscing elit,\n"
                      + "sed do eiusmod tempor incididunt ut\n"
                      + "labore et dolore magna aliqua.");
 );
Image of the Pagination control
Since:
JavaFX 2.2