APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.control

public Class Pagination

extends Control
Class Inheritance
Annotations
@DefaultProperty:pages
Imports
java.util.ArrayList, .Collections, .List, javafx.beans.DefaultProperty, javafx.beans.property.IntegerProperty, .ObjectProperty, .SimpleIntegerProperty, .SimpleObjectProperty, javafx.beans.value.ObservableValue, javafx.css.CssMetaData, .StyleableIntegerProperty, .Styleable, .StyleableProperty, javafx.scene.AccessibleRole, .Node, javafx.util.Callback, javafx.css.converter.SizeConverter, javafx.scene.control.skin.PaginationSkin

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField 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<Callback<Integer, Node>>
public static final String
STYLE_CLASS_BULLET

The style class to change the numeric page indicators to bullet indicators.

Constructor Summary

AccessConstructor 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 INDETERMINATE page count and a page index equal to zero.

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final IntegerProperty

Returns:

the current page index property
currentPageIndexProperty
()

The current page index to display for this pagination control.

public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final int

Returns:

the current page index
getCurrentPageIndex
()

Returns the current page index.

public final int

Returns:

the maximum number of page indicators
getMaxPageIndicatorCount
()

Returns the maximum number of page indicators.

public final int

Returns:

the number of pages
getPageCount
()

Returns the number of pages.

public final Callback<Integer, Node>

Returns:

the page factory callback function
getPageFactory
()

Returns the page factory callback function.

public final IntegerProperty

Returns:

the maximum number of page indicators to use for this pagination control
maxPageIndicatorCountProperty
()

The maximum number of page indicators to use for this pagination control.

public final IntegerProperty

Returns:

the number of pages for this pagination control
pageCountProperty
()

The number of pages for this pagination control.

public final ObjectProperty<Callback<Integer, Node>>

Returns:

the page factory property
pageFactoryProperty
()

The pageFactory callback function that is called when a page has been selected by the application or the user.

public final void
setCurrentPageIndex(int
the current page index.
value
)

Sets the current page index.

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
setPageCount(int
the number of pages
value
)

Sets the number of pages.

public final void
setPageFactory(Callback<Integer, Node>
the page factory callback function
value
)

Sets the page factory callback function.

Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenloadSkinClassqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty

Field Detail

currentPageIndexback to summary
private final IntegerProperty currentPageIndex
DEFAULT_MAX_PAGE_INDICATOR_COUNTback to summary
private static final int DEFAULT_MAX_PAGE_INDICATOR_COUNT
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
INDETERMINATEback to summary
public static final int INDETERMINATE

Value for indicating that the page count is indeterminate.

See Also
setPageCount(int)
maxPageIndicatorCountback to summary
private IntegerProperty maxPageIndicatorCount
oldMaxPageIndicatorCountback to summary
private int oldMaxPageIndicatorCount
oldPageCountback to summary
private int oldPageCount
pageCountback to summary
private IntegerProperty pageCount
pageFactoryback to summary
private ObjectProperty<Callback<Integer, Node>> pageFactory
STYLE_CLASS_BULLETback to summary
public static final String STYLE_CLASS_BULLET

The style class to change the numeric page indicators to bullet indicators.

Constructor Detail

Paginationback to summary
public Pagination(int pageCount, int pageIndex)

Constructs a new Pagination control with the specified page count and page index.

Parameters
pageCount:int

the number of pages for the pagination control

pageIndex:int

the index of the first page.

Paginationback to summary
public Pagination(int pageCount)

Constructs a new Pagination control with the specified page count.

Parameters
pageCount:int

the number of pages for the pagination control

Paginationback to summary
public Pagination()

Constructs a Pagination control with an INDETERMINATE page count and a page index equal to zero.

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.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(...).

Annotations
@Override
currentPageIndexPropertyback 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 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.

Returns:IntegerProperty

the current page index property

getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getControlCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Annotations
@Override
Since
JavaFX 8.0
getCurrentPageIndexback to summary
public final int getCurrentPageIndex()

Returns the current page index.

Returns:int

the current page index

getMaxPageIndicatorCountback to summary
public final int getMaxPageIndicatorCount()

Returns the maximum number of page indicators.

Returns:int

the maximum number of page indicators

getPageCountback to summary
public final int getPageCount()

Returns the number of pages.

Returns:int

the number of pages

getPageFactoryback to summary
public final Callback<Integer, Node> getPageFactory()

Returns the page factory callback function.

Returns:Callback<Integer, Node>

the page factory callback function

maxPageIndicatorCountPropertyback 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 pageCount. The number of page indicators will be reduced to fit the control if the maxPageIndicatorCount cannot fit. The default is 10 page indicators.

Returns:IntegerProperty

the maximum number of page indicators to use for this pagination control

pageCountPropertyback to summary
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.

Returns:IntegerProperty

the number of pages for this pagination control

pageFactoryPropertyback to summary
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.

Returns:ObjectProperty<Callback<Integer, Node>>

the page factory property

setCurrentPageIndexback to summary
public final void setCurrentPageIndex(int value)

Sets the current page index.

Parameters
value:int

the current page index.

setMaxPageIndicatorCountback to summary
public final void setMaxPageIndicatorCount(int value)

Sets the maximum number of page indicators.

Parameters
value:int

the number of page indicators. The default is 10.

setPageCountback to summary
public final void setPageCount(int value)

Sets the number of pages.

Parameters
value:int

the number of pages

setPageFactoryback to summary
public final void setPageFactory(Callback<Integer, Node> value)

Sets the page factory callback function.

Parameters
value:Callback<Integer, Node>

the page factory callback function

javafx.scene.control back to summary

private Class Pagination.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<Pagination, Number>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_PAGE_INDICATOR_COUNTback to summary
private static final CssMetaData<Pagination, Number> MAX_PAGE_INDICATOR_COUNT
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()