我有一个JTable
与一定数量的列(所有字符串)。我想实现一个过滤器,只显示包含相同字符串的column2和column3的行。 这可能吗?我尝试了regExp,但我没有看到比较表格单元值的方式。JTable使用RowFilter来比较两列
1
A
回答
3
直接实现的RowFilter:
RowFilter filter = new RowFilter<Object, Integer>() {
@Override
public boolean include(Entry entry) {
return entry.getValue(firstColumn).equals(entry.getValue(secondColumn));
}
}
(null检查和充分的仿制药省略)
2
您可以使用这些数据均列相互比较一个RowFilter。
http://download.oracle.com/javase/6/docs/api/javax/swing/RowFilter.html
0
//col as int is in outer class. Pls note col is your column to specify.
//So if you want more columns use || and with another column say col2.
class Columnfilter extends RowFilter<Object, Integer>
{ String txt=null;
Columnfilter(String txt){
this.txt=txt;
}
void setText(String txt){
this.txt=txt;
}
@Override
public boolean include(Entry entry) {
if(txt==null)return false;
if(col==-1)return true;//for all
String colVal= entry.getStringValue(col);//chk column if value exist
int b= colVal.toLowerCase().indexOf(txt.toLowerCase());
if(b!=-1){
return true;
}else{
return false;
}
}}
相关问题
- 1. JTable RowFilter
- 2. 使用Linq来比较两个列表
- 3. 比较两列
- 4. 使用RowFilter删除JTable中的一行
- 5. 使用JTable rowFilter进行高行排序
- 6. 两个日期之间的JTable rowfilter,同一列
- 7. Lambda来比较两个列表
- 8. 利用InStr比较两列
- 9. asp.net RowFilter比较字符串与int
- 10. Taffydb比较两列
- 11. c#列表比较器使用两个比较元素
- 12. JTable中,和的RowFilter RowFilter.Entry
- 13. 比较两张使用ID列
- 14. 使用MSpec比较两个列表
- 15. 比较两个列表,并使用LINQ
- 16. 如何比较两列,使用python?
- 17. 使用一列比较两个csv
- 18. 使用linq比较两个列表
- 19. 比较JTable中的2列日期
- 20. 使用grep来比较Python包的两个列表
- 21. 我可以在两列上使用COUNTIF来比较值吗?
- 22. 使用比较器来比较对象内的浮动列表
- 23. 使用strpos来比较阵列
- 24. 使用数组来比较表列值
- 25. JTable RowFilter不过滤初始调用
- 26. 比较两个使用Perl
- 27. 用来比较两个文件夹
- 28. 使用isEqualToString来比较NSString
- 29. 使用KNN来比较dataframes
- 30. 比较两个列表linq