How can I perform a case-insensitive filter on a JTable?

后端 未结 2 1172
野趣味
野趣味 2020-12-01 21:12

I am making a table with a text field below it where you can type in a word to filter the table. It works, but what I want to do is be able to filter it with the word typed

2条回答
  •  一向
    一向 (楼主)
    2020-12-01 21:49

    rowSorter.setStringConverter(new TableStringConverter() {
        @Override
        public String toString(TableModel model, int row, int column) {
            return model.getValueAt(row, column).toString().toLowerCase();
        }
    });
    rowSorter.setRowFilter(RowFilter.regexFilter(jtfFilter.getText().toLowerCase()));
    

提交回复
热议问题