在 Jtable 列中显示处理后的值并使用原始值排序?

Display processed values in Jtable column and sort using raw values?

我在数据库中有一个table,这个table的第一列包含一些数值,这是原始数据。有一种特定的算法可以将这些原始数值转换为经过处理的文本值。
我如何实现:

谢谢

原始数据应存储在 TableModel 中。渲染器用于控制 table 中显示的内容。例如,您将 123456 作为 Integer 存储在 TableModel 中,那么 Integers 的默认渲染器将在 table.

中显示“123,456”

所以在你的情况下你需要创建一个自定义渲染器。

看看Table Format Renderers。它显示了一个简单示例,说明如何覆盖 DefaultTableCellRenderer.

setValue(...) 方法

I want to sort rows in Jtable using this column but using the original raw numeric values, not the displayed processed text values. is this even possible?

是的,table 排序器根据 TableModel 中的数据进行排序。