[英]Get the ArrayList index of an element after using a row filter on a JTable
我有一个包含多个元素的ArrayList,每个元素包含下一个字段:
我有一个JTable来显示ArrayList中包含的信息。 根据某个字段,我有一个TableRowSorter来过滤信息。
假设在过滤后我只得到一个元素,因此JTable现在有一行。 如何在原始ArrayList中获取该元素的索引? 我是否必须再实施一种字段“ID”?
int viewIndex = 0; // the index in the table of the unique filtered row.
int modelIndex = table.convertRowIndexToModel();
modelIndex
是支持表模型的列表中的行的索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.