开发者

Why won't my TableRowFilter filter?

开发者 https://www.devze.com 2023-02-04 15:07 出处:网络
I\'m trying to filter a JTable using a TableRowFilter . It works for me on a simple example , but I can\'t seem to get it to work on the real thing. The filter is called , the logs are printed - but I

I'm trying to filter a JTable using a TableRowFilter . It works for me on a simple example , but I can't seem to get it to work on the real thing. The filter is called , the logs are printed - but I staill see the rows . Any ideas?

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.setRow开发者_StackOverflow中文版Filter(classFilter);
    return sorter;
}

...
}


As all stupid bugs go - this was one of them . In another class that use this table , I used table.setAutoCreateRowSorter(true) - so even thought the original sorter still ran , the default one also did , and then nothing happened.

0

精彩评论

暂无评论...
验证码 换一张
取 消