JTable行过滤器 [英] JTable RowFilter

查看:93
本文介绍了JTable行过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能如何获得与未过滤表相对应的选择的索引吗?

Is is possible to some how get the index of the selection corresponding to the non filtered table?

在使用regexFilter过滤表之后. JTable getSelectedRow返回过滤后的表的索引吗?

After the table is filter using a regexFilter. JTable getSelectedRow returns the index of the filtered table?

推荐答案

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

If you are using the built in TableRowSorter functionality from 1.6 you can use the convertRowIndexToModel() on the table. This is give you the unfiltered index of the selected row.

JTable的Javadoc对此进行了描述:

The javadoc for JTable gives a description of this:

坐标转换将是 使用基于行时需要 具有基础的JTable方法 TableModel.所有基于JTables的行 方法取决于RowSorter, 不一定和 基础TableModel的值.为了 例如,选择始终在 JTable的术语,以便在使用时 RowSorter您将需要转换 使用convertRowIndexToView或 convertRowIndexToModel.

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.

这篇关于JTable行过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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