且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在不单击列标题的情况下对JTable的条目进行排序

更新时间:2023-12-04 18:38:10

您有一个自定义的比较器(为什么保留对分类器的引用?看起来很腥)自定义RowSorter.

as far as I can see you have a custom comparator (why does that keep a reference to the sorter? looks fishy) not a custom RowSorter.

更改排序的预期方法是在RowSorter上调用toggleSortOrder(column).要获得更细粒度的控制,您可能需要访问DefaultRowSorter,f.i.其setSortKeys方法.

The intended way to change sorting is to invoke toggleSortOrder(column) on RowSorter. For more fine-grained control you can need access to the DefaultRowSorter, f.i. its setSortKeys method.