Question

I already have this:

TableRowSorter<FileTableModel> rs = new TableRowSorter<FileTableModel>(ftm);
    rs.setComparator(COL_NAME, new Comparator<DisplayFile>() {
            //<sorting code>
        }
    });
    setRowSorter(rs);

and it works. It sorts the rows as it should when the user clicks on the header. I just can't figure out an easy way to sort the rows without the click on the header. I want rows to already be sorted when they are displayed (user can then change asc/desc/etc. by clicking on column headers.)

How can i force the sorting? I know I could sort the rows in my TableModel, but i already have a working comparator, why not use it?

Was it helpful?

Solution

rowSorter.toggleSortOrder(colIndex);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top