Domanda

Say I have a table that the first column is id, and I want the table to be sorted by id number when it is created. What can I do?

I hope 'sorting before the construction of the table' is not the only solution.

È stato utile?

Soluzione

Try this code

JTable table = new JTable();
table.setAutoCreateRowSorter(true);
table.getRowSorter().toggleSortOrder(0);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top