0
我正在嘗試使用TableRowFilter來過濾一個JTable。它對我來說是一個簡單的例子,但我似乎無法讓它在真實的事情上工作。過濾器被稱爲,日誌打印 - 但我staill看到的行。有任何想法嗎?爲什麼我的TableRowFilter過濾器不會?
public class TopicTable extends JTable {
...
public TopicTable(ITopic topic) {
super();
TopicTableDataModel model = new TopicTableDataModel(topic);
setModel(model);
setRowSorter(generateTableRowSorter(model));
setFillsViewportHeight(true);
setColumnRenderers();
}
private TableRowSorter<TableModel> generateTableRowSorter(TableModel model) {
RowFilter<Object, Object> classFilter = new RowFilter<Object, Object>() {
@Override
public boolean include(javax.swing.RowFilter.Entry<? extends Object, ? extends Object> entry) {
log.debug("Filtering? " + entry.getValue(1));
return false;
}
};
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
sorter.setRowFilter(classFilter);
return sorter;
}
...
}
你簡單的例子和複雜的例子有什麼不同? – I82Much 2011-01-11 19:17:22