How to remove the filter in a JTable


I'm making a table in which I need to filter some data, I do this with a combobox, to filter it works well, but when I select the index 0 item (default) it does not return the table to its normal state What do I do?

I use this code.

public void itemStateChanged(ItemEvent e) {
        if (e.getSource() == this.jCarreras) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                int index = this.jCarreras.getSelectedIndex();
                String item = (String) (this.jCarreras.getSelectedItem());
                if (index > 0) {

                    this.sorter.setRowFilter(RowFilter.regexFilter(item, 5));



How can I do so that when the index is 0, I return all the information from the original table?

asked by Santiago Arevalo Gómez 16.11.2018 в 02:56

1 answer


Since the problem is not in the combobox, but in the table ... habitually the Jtable is used with DefaultTableModel ... so the table only changes its visual way, not of data itself. .

Therefore in the table you should have something like that ....

   DefaultTableModel modelo = (DefaultTableModel) tblDatos.getModel();
    int selectRowIndex = tblDatos.getSelectedRow();
    if (selectRowIndex >= 0) {
        idMuestras = (int) modelo.getValueAt(selectRowIndex, 0);

where model.getvalue you should change the tblDatos.getValue

answered by 16.11.2018 в 20:59