将anFilter与orFIlter

时间:2015-04-22 09:48:25

标签: java swing jtable rowfilter

我有一个名为newFilter

的rowfilter的以下代码
private void newFilter()
{
    RowFilter rfb = null;
    try //try catch block
    {
        List<RowFilter<Object,Object>> filtersb = new ArrayList<RowFilter<Object,Object>>(3);
        filtersb.add(RowFilter.regexFilter("(?i)"+filterAthID.getText(), 0));
        filtersb.add(RowFilter.regexFilter("(?i)"+filterForeName.getText(), 1));
        filtersb.add(RowFilter.regexFilter("(?i)"+filterDate.getText(), 2));
        rfb = RowFilter.andFilter(filtersb);

        if(Blank.isShowing()==true)
        {
            List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>(2);
            filters.add(RowFilter.regexFilter("(?i)"+filterForeName.getText(), 1));
            filters.add(RowFilter.regexFilter("(?i)"+filterForeName.getText(), 2));
            rfb = RowFilter.orFilter(filters);
        }

    } 
    catch (java.util.regex.PatternSyntaxException e)
    {
        return;
    }
    sorter.setRowFilter(rfb);
}

我尝试组合两个过滤器,以便在显示Blank时,它将使用andFilter以及orFilter。但是这不起作用,因为rfb一次只能连接一个过滤器。这引出了一个问题,我如何组合两个行过滤器,以便在显示Blank时系统使用filterAthID来搜索第0列 {{1}搜索第1列 2?

0 个答案:

没有答案