java - JTable 行过滤器

标签 java swing jtable rowfilter tablerowsorter

有没有可能一些如何获得非过滤表对应的选择的索引?

在表格之后使用 regexFilter 进行过滤。 JTable getSelectedRow 返回筛选表的索引?

最佳答案

如果您使用的是 1.6 中内置的 TableRowSorter 功能,则可以在表格上使用 convertRowIndexToModel()。这会为您提供所选行的未过滤索引。

JTable 的 javadoc 对此进行了描述:

Coordinate conversions will be necessary when using the row based methods of JTable with the underlying TableModel. All of JTables row based methods are in terms of the RowSorter, which is not necessarily the same as that of the underlying TableModel. For example, the selection is always in terms of JTable so that when using RowSorter you will need to convert using convertRowIndexToView or convertRowIndexToModel.

关于java - JTable 行过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1316388/

相关文章:

java - hibernate 日期转换

java - fragment 、AsyncTask 和监听器

java - JFrame:WAITING按下表单上的按钮以接收类中的值并继续

java - 使用 JTable 条目作为按钮

java - 如何防止 Jtable 和 MYSQL(数据库)中的重复条目?

java - 如何通过单元测试验证是否记录了错误

java - 如何对动态呈现 html 和 css 的 Java 代码进行单元测试?

java - 默认表模型为空?

java - 更改选项框的颜色和大小 JOptionPane.showInputDialog

java - JXTable 和滚动条上方的标题单元格