문제

is there anyway to invoke the auto row sorter in a jtable that is created by using

setAutoCreateRowSorter(true);

i'm trying to get it to sort by a default column without the user having to click on on the column header.

도움이 되었습니까?

해결책

table.getRowSorter().toggleSortOrder(modelColumnIndex)

다른 팁

TableRowSorter rowSorter = (TableRowSorter) table.getRowSorter();
List<SortKey> keys = new ArrayList<SortKey>();
SortKey sortKey = new SortKey(2, SortOrder.ASCENDING);//column index 2
keys.add(sortKey);
rowSorter.setSortKeys(keys);
rowSorter.sort();

i'm trying to get it to sort by a default column without the user having to click on on the column header.

I think you have to use setSortsOnUpdates(true) method from TableRowSorter class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top