问题描述:

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?

网友答案:
rowSorter.toggleSortOrder(colIndex);
相关阅读:
Top