JTreeTable显示问题
我有以下问题.. 我创建了一个 JTreeTable 和一个扩展 AbstractTreeTableModel 的模型。 问题是,仅当我在每次插入操作后调用 fireTreeStructureChanged() 方法时,才会显示我的数据。事实上,如果我简单地触发 fireTreeNodesInserted() 方法,什么也不会发生。
此外,我行中的数据仅在添加/删除事件后更新,如果它们简单地更改其值,则仅在单击表格后更新。
怎么可能呢?
编辑
当我调用 fireTreeStructureChanged() 时,它会调用方法 fireTableDataChanged();相反, fireTreeNodesInserted(intfirstRow, intlastRow) 调用 fireTableRowsInserted();但也许我传递给它的参数不正确......我必须传递哪一行和最后一行?
I've the following problem..
I've created a JTreeTable and a model which extends AbstractTreeTableModel.
The problem is that my data are shown only if I call the fireTreeStructureChanged() method after each inserting operation. In fact if I simple fire the method fireTreeNodesInserted(), nothing happens.
Besides, the data in my row are updated only after an add/remove event, if they simple change their value they are updated only after a click on the table.
How is it possible?
EDIT
When I call fireTreeStructureChanged() then it calls the method fireTableDataChanged(); instead the fireTreeNodesInserted(int firstRow, int lastRow) calls fireTableRowsInserted(); but maybe I pass to it the incorrect parameters...which first and last row I have to pass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了减轻事件触发的痛苦,SwingX 有一个辅助类 TreeModelSupport,它可以独立于项目使用
编辑
这是标准方式:-) 经过充分测试的 TreeModelEvent 和 TreeModelListener 中 api 文档的 1:1 映射,阅读它将帮助您理解。
To alleviate the pain of event firing, SwingX has a helper class TreeModelSupport which is usable independent of the project
Edit
that is the standard way :-) A well tested 1:1 mapping of api doc in TreeModelEvent and TreeModelListener, reading it will help you understand.