A Pagination control is used for navigation between pages of a single content, which has been divided into smaller parts.
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).
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.
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.
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.");
);
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final IntegerProperty | |
| private static final int | |
| private static final String | |
| public static final int | INDETERMINATE
Value for indicating that the page count is indeterminate. |
| private IntegerProperty | |
| private int | |
| private int | |
| private IntegerProperty | |
| private ObjectProperty | |
| public static final String | STYLE_CLASS_BULLET
The style class to change the numeric page indicators to bullet indicators. |
| Access | Constructor and Description |
|---|---|
| public | Pagination(int
the number of pages for the pagination control pageCount, int the index of the first page. pageIndex)Constructs a new Pagination control with the specified page count and page index. |
| public | Pagination(int
the number of pages for the pagination control pageCount)Constructs a new Pagination control with the specified page count. |
| public | Pagination()
Constructs a Pagination control with an |
| Modifier and Type | Method and Description |
|---|---|
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final IntegerProperty | Returns: the current page index propertyThe current page index to display for this pagination control. |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final int | |
| public final int | Returns: the maximum number of page indicatorsReturns the maximum number of page indicators. |
| public final int | |
| public final Callback | Returns: the page factory callback functionReturns the page factory callback function. |
| public final IntegerProperty | Returns: the maximum number of page indicators to use for this pagination controlThe maximum number of page indicators to use for this pagination control. |
| public final IntegerProperty | Returns: the number of pages for this pagination controlThe number of pages for this pagination control. |
| public final ObjectProperty | Returns: the page factory propertyThe pageFactory callback function that is called when a page has been selected by the application or the user. |
| public final void | |
| public final void | setMaxPageIndicatorCount(int
the number of page indicators. The default is 10. value)Sets the maximum number of page indicators. |
| public final void | |
| public final void | setPageFactory(Callback<Integer, Node>
the page factory callback function value)Sets the page factory callback function. |
| currentPageIndex | back to summary |
|---|---|
| private final IntegerProperty currentPageIndex | |
| DEFAULT_MAX_PAGE_INDICATOR_COUNT | back to summary |
|---|---|
| private static final int DEFAULT_MAX_PAGE_INDICATOR_COUNT | |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| INDETERMINATE | back to summary |
|---|---|
| public static final int INDETERMINATE Value for indicating that the page count is indeterminate.
| |
| maxPageIndicatorCount | back to summary |
|---|---|
| private IntegerProperty maxPageIndicatorCount | |
| oldMaxPageIndicatorCount | back to summary |
|---|---|
| private int oldMaxPageIndicatorCount | |
| oldPageCount | back to summary |
|---|---|
| private int oldPageCount | |
| pageCount | back to summary |
|---|---|
| private IntegerProperty pageCount | |
| pageFactory | back to summary |
|---|---|
| private ObjectProperty<Callback<Integer, Node>> pageFactory | |
| STYLE_CLASS_BULLET | back to summary |
|---|---|
| public static final String STYLE_CLASS_BULLET The style class to change the numeric page indicators to bullet indicators. | |
| Pagination | back to summary |
|---|---|
| public Pagination(int pageCount, int pageIndex) Constructs a new Pagination control with the specified page count and page index.
| |
| Pagination | back to summary |
|---|---|
| public Pagination(int pageCount) Constructs a new Pagination control with the specified page count.
| |
| Pagination | back to summary |
|---|---|
| public Pagination() Constructs a Pagination control with an | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. 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 | |
| currentPageIndexProperty | back to summary |
|---|---|
| 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
Because the page indicators set the current page index, the currentPageIndex property permits only
bidirectional binding.
The
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getCurrentPageIndex | back to summary |
|---|---|
| public final int getCurrentPageIndex() Returns the current page index.
| |
| getMaxPageIndicatorCount | back to summary |
|---|---|
| public final int getMaxPageIndicatorCount() Returns the maximum number of page indicators.
| |
| getPageCount | back to summary |
|---|---|
| public final int getPageCount() Returns the number of pages.
| |
| getPageFactory | back to summary |
|---|---|
| public final Callback Returns the page factory callback function. | |
| maxPageIndicatorCountProperty | back to summary |
|---|---|
| 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
| |
| pageCountProperty | back to summary |
|---|---|
| public final IntegerProperty pageCountProperty() The number of pages for this pagination control. This
value must be greater than or equal to 1.
| |
| pageFactoryProperty | back to summary |
|---|---|
| public final ObjectProperty 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.
| |
| setCurrentPageIndex | back to summary |
|---|---|
| public final void setCurrentPageIndex(int value) Sets the current page index.
| |
| setMaxPageIndicatorCount | back to summary |
|---|---|
| public final void setMaxPageIndicatorCount(int value) Sets the maximum number of page indicators.
| |
| setPageCount | back to summary |
|---|---|
| public final void setPageCount(int value) Sets the number of pages.
| |
| setPageFactory | back to summary |
|---|---|
| public final void setPageFactory(Callback<Integer, Node> value) Sets the page factory callback function. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| private |
| MAX_PAGE_INDICATOR_COUNT | back to summary |
|---|---|
| private static final CssMetaData<Pagination, Number> MAX_PAGE_INDICATOR_COUNT | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |