Skip to main content
A pagination control that displays page numbers and navigation buttons, allowing users to browse through paginated content.

Constructor

JPagination()
constructor
Creates a new pagination component with default settings (page 1 of 1).

Properties

currentPageProperty()
IntegerProperty
Returns the current page number property for binding.
returns
IntegerProperty
The observable current page property (1-indexed)
totalPagesProperty()
IntegerProperty
Returns the total pages property for binding.

Methods

setOnPageChange(Runnable action)
void
Sets the callback to execute when the page changes.

Usage Example

JPagination pagination = new JPagination();

// Set total pages
pagination.totalPagesProperty().set(10);

// Listen to page changes
pagination.setOnPageChange(() -> {
    int currentPage = pagination.currentPageProperty().get();
    loadPageData(currentPage);
});

// Programmatically change page
pagination.currentPageProperty().set(3);

Behavior

  • Displays page numbers with ellipsis (…) for large page ranges
  • Shows up to 7 page buttons at a time
  • Always displays first and last page
  • Previous button is disabled on first page
  • Next button is disabled on last page
  • Active page is highlighted

Page Number Display Logic

  • 7 or fewer pages: Shows all page numbers
  • More than 7 pages: Shows first page, current page ± 1, last page, with ellipsis between ranges

Style Classes

  • .j-pagination - Main container
  • .j-pagination-btn - Page button
  • .active - Active page button
  • .disabled - Disabled button (ellipsis)

Build docs developers (and LLMs) love