0

I need help in making the RowFilter work. I'm trying to filter the 3rd column using the checkboxes below. It works fine when I click one of them but it doesn't work when multiple checkboxes are selected.

Any help would be very much appreciated. Full explanation would also help very much. Thanks in advance!

private void newFilter() {
    RowFilter<DefaultTableModel, Object> rf = null;
    java.util.List<RowFilter<Object,Object>> rfs = 
            new ArrayList<RowFilter<Object,Object>>(2);

    try {

        //Filter "Full Name" using TextField
        rfs.add(RowFilter.regexFilter("(?i)" + textField.getText(), 0)); 

        /*  Filter "Employee Type" using CheckBoxes
         *  ex. If both chckbxAdmin and chckbxEmployee is checked, 
         *  Jtable will filter accordingly
         */
        rfs.add(RowFilter.regexFilter("(?i)" + sfAdmin, 2));
        rfs.add(RowFilter.regexFilter("(?i)" + sfEmployee, 2));
        rfs.add(RowFilter.regexFilter("(?i)" + sfStaff, 2));

    } catch (java.util.regex.PatternSyntaxException e) {
        e.printStackTrace();
    }

    RowFilter<Object,Object> af = RowFilter.andFilter(rfs);

    sorter.setRowFilter(af);

}
mKorbel
  • 109,525
  • 20
  • 134
  • 319
mfrancisp
  • 119
  • 1
  • 2
  • 12

0 Answers0