JavaFX分页,添加<<和>>>选项 [英] JavaFX Pagination, adding << and >>> options

查看:761
本文介绍了JavaFX分页,添加<<和>>>选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个数据显示应用程序,我需要为我的分页添加一个选项,可用于返回第一页(索引)或转到最后一页。

I am doing a data displaying app and I need to add a option to my pagination which can be used to go back to the first page (index) or go to the last one.

我已经尝试过向我的用户界面添加按钮,但由于无法获取最后一个索引而无效。

I already tried adding buttons to my UI but it did not work because I could not obtain the last index.

@FXML
void goToLastIndex(ActionEvent event) {
    int lastIndex = pagination.getPageCount();
    pagination.setCurrentPageIndex(lastIndex);
}


推荐答案

根据 Javadocs 默认值 pageCount Pagination.INDETERMINATE ,这是(或多或少任意)等于 Integer.MAX_VALUE 。如果您的分页具有固定数量的页面(如果没有,那么拥有最后一页真的没有意义),那么您应该通过调用构造函数获取页数值,或者调用 setPageCount(...)并指定页数。

According to the Javadocs the default value of pageCount is Pagination.INDETERMINATE, which is (more or less arbitrarily) equal to Integer.MAX_VALUE. If your pagination has a fixed number of pages (if not, it doesn't really make sense to have a "last page"), then you should initialize it by calling the constructor taking a page count value, or call setPageCount(...) and specify the number of pages.

这篇关于JavaFX分页,添加<<和>>>选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆