JavaFX TableView Paginator


How use in TableView paginator.?.For This exmple...

public class SampleController implements Initializable {

    @FXML private TableView<Student> table;
    @FXML private TableColumn<Student, Integer> id;
    @FXML private TableColumn<Student, String> name;
    @FXML private ObservableList<Student> list = FXCollections.observableArrayList();
    //  @FXML private Pagination pagination;
    private StudentSQL ssql = new StudentSQL();
    private Stage stage = new Stage();
    private String row;

    public void initialize(URL url, ResourceBundle rb) {
        id.setCellValueFactory(new PropertyValueFactory<Student, Integer>("id"));
        name.setCellValueFactory(new PropertyValueFactory<Student, String>("name"));
        list = ssql.students();
8/21/2014 4:52:47 PM

You have to use the Pagination control and implement a page factory. The factory is called for every page that should be displayed and you can use its parameter, the pageIndex, to provide a sublist of items to the TableView:

TableView table = ...

private Node createPage(int pageIndex) {

    int fromIndex = pageIndex * rowsPerPage;
    int toIndex = Math.min(fromIndex + rowsPerPage, data.size());
    table.setItems(FXCollections.observableArrayList(data.subList(fromIndex, toIndex)));

    return new BorderPane(table);

public void start(final Stage stage) throws Exception {

    Pagination pagination = new Pagination((data.size() / rowsPerPage + 1), 0);

A complete runnable example can be found here:

8/21/2014 10:38:20 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow