有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JTable行过滤器

是否有可能获得与未筛选表相对应的选择的索引

在使用regexFilter筛选表之后。JTable getSelectedRow返回筛选表的索引


共 (1) 个答案

  1. # 1 楼答案

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

    javadoc for JTable对此进行了描述:

    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.