JTable AutoSorter in columns

-1

I'm a few years old with a problem that I still can not solve completely today. When I add a TableRowSorter to a JTable automatically the columns can be ordered by clicking and thus I have a problem getting the correct index, yes already I tried to use ConvertIndexToView and ConvertIndexToModel , I already searched in several places in how to disable the autosorter option by clicking on the columns but without success.

Here it is working perfectly I selected index 1 and the record came correct according to the number selected

SecondImagewitherror,alreadyinthisIselectedtheindex1andwiththeactivefilterasshownpullsmethesamerecordasinthepreviousimageotherthantheview

asked by anonymous 09.11.2017 / 12:52

1 answer

0

I got a lot of research on how to disable autosorter that happened by clicking on the columns of JTable just overwriting the method isSortable of TableRowSorter to return false to all columns thus clicking the columns the user You can no longer sort the data.

TableRowSorter sorter = new TableRowSorter(tabela.getModel()){
            @Override
            public boolean isSortable(int column) {
                return false; 
            }            
        };
    
09.11.2017 / 13:10