I have a JTable that has several columns. I wanted to make some of the columns unsortable. How do I do it? I am stuck using Java 1.4 so using TableRowSorter isn't an option since it wasn't introduced until 1.6.
解决方案
apply RowSorter to the desired column(s) only
(for example, only pseudo_code, everything is there hardcoded as example, have to override columns from ColumnModel)
if (column >= 0 && column < getModelWrapper().getColumnCount()
&& isSortable(column)) {
with
if (column >= 0 && column <=1 /*getModelWrapper().getColumnCount()*/
&& isSortable(column)) {
in public void toggleSortOrder(int column) {
then second column isn't sortable
if not help you for better help sooner post an SSCCE demonstrated your issue
在Java 1.4环境下,由于TableRowSorter在1.6之后才引入,因此无法直接使用。要使JTable的部分列不可排序,可以检查列索引并阻止特定列的排序操作。在toggleSortOrder方法中,通过添加条件判断来实现这一功能。
868

被折叠的 条评论
为什么被折叠?



