Java JTable行分拣机-过滤器管理
我有一个行筛选器,但我需要加载除值以外的所有内容 例如:Java JTable行分拣机-过滤器管理,java,jtable,rowfilter,Java,Jtable,Rowfilter,我有一个行筛选器,但我需要加载除值以外的所有内容 例如: col1 | col2 ----------- 1 | N 2 | Y 3 | O 我需要的是: col1 | col2 ----------- 1 | N 3 | O 我所拥有的: RowFilter<TableModel, Object> firstFiler = null; List<RowFilter<TableModel, Object>> filters =
col1 | col2
-----------
1 | N
2 | Y
3 | O
我需要的是:
col1 | col2
-----------
1 | N
3 | O
我所拥有的:
RowFilter<TableModel, Object> firstFiler = null;
List<RowFilter<TableModel, Object>> filters = new
ArrayList<RowFilter<TableModel, Object>>();
RowFilter<TableModel, Object> compoundRowFilter = null;
try {
firstFiler = RowFilter.regexFilter("(?i)" + text, 1);
filters.add(firstFiler);
compoundRowFilter = RowFilter.andFilter(filters);
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
sorter.setRowFilter(compoundRowFilter);
RowFilter firstFiler=null;
列表过滤器=新建
ArrayList();
RowFilter compoundRowFilter=null;
试一试{
firstFiler=RowFilter.regexFilter(“(?i)”+文本,1);
filters.add(firstFiler);
compoundRowFilter=RowFilter.andFilter(过滤器);
}catch(java.util.regex.PatternSyntaxException e){
返回;
}
分拣机。设置行过滤器(复合行过滤器);
参见JavaDoc中的示例:
上面JavaDoc链接中的以下示例显示了一个include方法,该方法只允许包含一个或多个以字符串“a”开头的值的条目:
RowFilter startsWithAFilter=newrowfilter(){
公共布尔包含(条目参见JavaDoc中的示例:
上面JavaDoc链接中的以下示例显示了一个include方法,该方法只允许包含一个或多个以字符串“a”开头的值的条目:
RowFilter startsWithAFilter=newrowfilter(){
公共布尔包含(条目
RowFilter<Object,Object> startsWithAFilter = new RowFilter<Object,Object>() {
public boolean include(Entry<? extends Object, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--){
if(entry.getStringValue(i).startsWith("a")) {
// The value starts with "a", include it
return true;
}
}
// None of the columns start with "a"; return false so that this
// entry is not shown
return false;
}
};