当更新树时,JTree避免崩溃节点。

时间:2021-02-08 12:36:48

I'm using a tree table object (the example taken from the sun site)..I would prevent the collapse of the tree nodes when I update the model, because it's boring to re-expand all the nodes everytime I need to update it. Can you help me? Thank you!

我使用的是一个tree table对象(取自sun站点的示例)。当我更新模型时,我将防止树节点的崩溃,因为每当我需要更新它时,重新扩展所有的节点是很烦人的。你能帮我吗?谢谢你们!

1 个解决方案

#1


1  

Without seeing the model and without knowing what exactly you mean by "update the model", just a couple of facts

没有看到模型,也不知道“更新模型”到底是什么意思,只是一些事实。

  • structure change: no way, the tree cant know if/when/which nodes are the same as before
  • 结构变化:no way, the tree can know if/when/哪个节点和以前一样。
  • insert/remove: shouldn't touch expansion state of unrelated nodes
  • 插入/删除:不应触及无关节点的扩展状态。
  • valueChanged: shouldn't touch expansion state at all
  • valueChanged:不应该触及扩展状态。

Check your model implementation if it always fires the most narrow event possible. Then check how it behaves in a plain ol' JTree: if it's okay there, then the TreeTable has a glitch (BTW: SwingX has a newer version :-)

检查您的模型实现,如果它总是触发最狭窄的事件可能。然后检查它在普通的ol' JTree中的行为:如果它在那里,那么TreeTable有一个小故障(BTW: SwingX有一个较新的版本:-)

#1


1  

Without seeing the model and without knowing what exactly you mean by "update the model", just a couple of facts

没有看到模型,也不知道“更新模型”到底是什么意思,只是一些事实。

  • structure change: no way, the tree cant know if/when/which nodes are the same as before
  • 结构变化:no way, the tree can know if/when/哪个节点和以前一样。
  • insert/remove: shouldn't touch expansion state of unrelated nodes
  • 插入/删除:不应触及无关节点的扩展状态。
  • valueChanged: shouldn't touch expansion state at all
  • valueChanged:不应该触及扩展状态。

Check your model implementation if it always fires the most narrow event possible. Then check how it behaves in a plain ol' JTree: if it's okay there, then the TreeTable has a glitch (BTW: SwingX has a newer version :-)

检查您的模型实现,如果它总是触发最狭窄的事件可能。然后检查它在普通的ol' JTree中的行为:如果它在那里,那么TreeTable有一个小故障(BTW: SwingX有一个较新的版本:-)