JTable duplicate values in row(行中的 JTable 重复值)
问题描述
我有一个 JTable 填充了自定义
DataModel
(粘贴在下面),当我调用 populate()
方法时,它 似乎用重复的数据填充表格 - 每行一遍又一遍地填充相同的值.然而,仔细检查(通过简单地 println()ing 'data' 字段),数据模型没有错误 - 它以我期望的格式保存正确的数据.什么给了?
I have a JTable
populated with a custom DataModel
(pasted below) and when I call the populate()
method, it appears to populate the table with duplicate data - each row is filled with the same value over and over again. However, on closer inspection (by simply println()ing the 'data' field), the data model isn't at fault - it holds correct data, in the format I expect. What gives?
推荐答案
这里有一个完整的例子,可能会很有帮助.由于示例
和 Map
是不可修改的,我建议您参考 @mKorbel 的 example 关于如何覆盖 <代码>isCellEditable()setValueAt()
.
Here's a complete example that may prove helpful. As the sample Map
is unmodifiable, I refer you to @mKorbel's example on how to override isCellEditable()
and setValueAt()
.
这篇关于行中的 JTable 重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!