且构网

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

在JTable中使用setAutoCreateRowSorter对不同的数据类型进行排序

更新时间:2023-12-04 19:26:10

问题是,您告诉JTable您所有的列都包含Strings(包括最后一个字符串),这是不正确的:

The problem is that you told the JTable that all your columns contain Strings (escpt the last one), which is not true:

public Class<?> getColumnClass(int columnIndex) {
    if (columnIndex == numberOfColumns) {
        return Boolean.class;
    } else {
        //return getValueAt(0, columnIndex).getClass();
        return String.class;
    }
}

将事实告诉JTable,它将很高兴.

Tell the truth to the JTable, and it will be happy.