TreeModel 的自定义实现在调用 treeNodesInserted 后拒绝重新绘制
我正在为 JTree 使用自定义 TreeModel。当我将新节点插入到 TreeModel 中,然后在所有 TreeModelListener 上调用 treeNodesInserted(TreeModelEvent) 时,出现问题。
我认为这个问题与 JTree.TreeModelHandler 没有对 treeNodesInserted(e) 的实现有关,只有 treeStructureChanged(e)
显然对我来说能够插入会好得多,而不是更改完整的树结构。
有解决方法吗? (我不能使用DefaultTreeModel)
I'm using a custom TreeModel for a JTree. I have an issue when I insert a new node into my TreeModel, and then call treeNodesInserted(TreeModelEvent) on all my TreeModelListeners.
I think the issue has to do with the fact that JTree.TreeModelHandler has no implementation for treeNodesInserted(e), only treeStructureChanged(e)
obviously for me it would be a lot better to be able to insert, instead of a full tree structure changed.
Is there a workaround? (I can't use DefaultTreeModel)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更多细节会有所帮助。但我也做过类似的事情,没有任何问题。就我而言,我已经让 MyTreeModel 实现了 TreeModel,并且 fireTreeInserts 函数是其中的一部分。
该函数看起来像这样(清理后的应用程序特定代码):
Some more details would help. But I have done a similar thing with no issues. In my case I've got MyTreeModel implements TreeModel, and a fireTreeInserts function is part of it.
The function looks something like this (cleaned application specific code):