Class Pagination

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.

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.");
     }
 });
Image of the Pagination control
Since:
JavaFX 2.2
  • Property Details

    • maxPageIndicatorCount

      public final IntegerProperty maxPageIndicatorCountProperty
      The maximum number of page indicators to use for this pagination control. The maximum number of pages indicators will remain unchanged if the value is less than 1 or greater than the pageCount. The number of page indicators will be reduced to fit the control if the maxPageIndicatorCount cannot fit. The default is 10 page indicators.
      See Also:
      getMaxPageIndicatorCount(), setMaxPageIndicatorCount(int)
    • pageCount

      public final IntegerProperty pageCountProperty
      The number of pages for this pagination control. This value must be greater than or equal to 1. INDETERMINATE should be used as the page count if the total number of pages is unknown. The default is an INDETERMINATE number of pages.
      See Also:
      getPageCount(), setPageCount(int)
    • currentPageIndex

      public final IntegerProperty currentPageIndexProperty
      The current page index to display for this pagination control. The first page will be the current page if the value is less than 0. Similarly the last page will be the current page if the value is greater than the pageCount The default is 0 for the first page.

      Because the page indicators set the current page index, the currentPageIndex property permits only bidirectional binding. The bind method throws an UnsupportedOperationException.

      See Also:
      getCurrentPageIndex(), setCurrentPageIndex(int)
    • pageFactory

      public final ObjectProperty<Callback<Integer,​Node>> pageFactoryProperty
      The pageFactory callback function that is called when a page has been selected by the application or the user. This function is required for the functionality of the pagination control. The callback function should load and return the contents the page index. Null should be returned if the page index does not exist. The currentPageIndex will not change when null is returned. The default is null if there is no page factory set.
      See Also:
      getPageFactory(), setPageFactory(Callback)
  • Field Details

  • Constructor Details

    • Pagination

      public Pagination​(int pageCount, int pageIndex)
      Constructs a new Pagination control with the specified page count and page index.
      Parameters:
      pageCount - the number of pages for the pagination control
      pageIndex - the index of the first page.
    • Pagination

      public Pagination​(int pageCount)
      Constructs a new Pagination control with the specified page count.
      Parameters:
      pageCount - the number of pages for the pagination control
    • Pagination

      public Pagination()
      Constructs a Pagination control with an INDETERMINATE page count and a page index equal to zero.
  • Method Details

    • setMaxPageIndicatorCount

      public final void setMaxPageIndicatorCount​(int value)
      Sets the maximum number of page indicators.
      Parameters:
      value - the number of page indicators. The default is 10.
    • getMaxPageIndicatorCount

      public final int getMaxPageIndicatorCount()
      Returns the maximum number of page indicators.
      Returns:
      the maximum number of page indicators
    • maxPageIndicatorCountProperty

      public final IntegerProperty maxPageIndicatorCountProperty()
      The maximum number of page indicators to use for this pagination control. The maximum number of pages indicators will remain unchanged if the value is less than 1 or greater than the pageCount. The number of page indicators will be reduced to fit the control if the maxPageIndicatorCount cannot fit. The default is 10 page indicators.
      See Also:
      getMaxPageIndicatorCount(), setMaxPageIndicatorCount(int)
    • setPageCount

      public final void setPageCount​(int value)
      Sets the number of pages.
      Parameters:
      value - the number of pages
    • getPageCount

      public final int getPageCount()
      Returns the number of pages.
      Returns:
      the number of pages
    • pageCountProperty

      public final IntegerProperty pageCountProperty()
      The number of pages for this pagination control. This value must be greater than or equal to 1. INDETERMINATE should be used as the page count if the total number of pages is unknown. The default is an INDETERMINATE number of pages.
      See Also:
      getPageCount(), setPageCount(int)
    • setCurrentPageIndex

      public final void setCurrentPageIndex​(int value)
      Sets the current page index.
      Parameters:
      value - the current page index.
    • getCurrentPageIndex

      public final int getCurrentPageIndex()
      Returns the current page index.
      Returns:
      the current page index
    • currentPageIndexProperty

      public final IntegerProperty currentPageIndexProperty()
      The current page index to display for this pagination control. The first page will be the current page if the value is less than 0. Similarly the last page will be the current page if the value is greater than the pageCount The default is 0 for the first page.

      Because the page indicators set the current page index, the currentPageIndex property permits only bidirectional binding. The bind method throws an UnsupportedOperationException.

      See Also:
      getCurrentPageIndex(), setCurrentPageIndex(int)
    • setPageFactory

      public final void setPageFactory​(Callback<Integer,​Node> value)
      Sets the page factory callback function.
      Parameters:
      value - the page factory callback function
    • getPageFactory

      public final Callback<Integer,​Node> getPageFactory()
      Returns the page factory callback function.
      Returns:
      the page factory callback function
    • pageFactoryProperty

      public final ObjectProperty<Callback<Integer,​Node>> pageFactoryProperty()
      The pageFactory callback function that is called when a page has been selected by the application or the user. This function is required for the functionality of the pagination control. The callback function should load and return the contents the page index. Null should be returned if the page index does not exist. The currentPageIndex will not change when null is returned. The default is null if there is no page factory set.
      See Also:
      getPageFactory(), setPageFactory(Callback)
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).
      Overrides:
      createDefaultSkin in class Control
      Returns:
      new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
    • getClassCssMetaData

      public static List<CssMetaData<? extends Styleable,​?>> getClassCssMetaData()
      Returns:
      The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Since:
      JavaFX 8.0
    • getControlCssMetaData

      public List<CssMetaData<? extends Styleable,​?>> getControlCssMetaData()
      Overrides:
      getControlCssMetaData in class Control
      Returns:
      unmodifiable list of the controls css styleable properties
      Since:
      JavaFX 8.0