我有一个 GUI,它连接到数据库并将表的结果返回到 JTable,但是,当我单击名为“ID”的列时;排序如下:
1
10
100
1000
10000
2
20
200
...
我该如何解决这个问题?
最佳答案
您需要存储
Integer
TableMedel
中的对象,而不是字符串您需要覆盖
getColumnClass(...)
你的方法TableModel
返回 Integer.class,因此正确的Comparator
可以使用。
关于java - JTable AutoCreateSorter 排序不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46473684/