JTree avoid collapse node when update the tree

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 01:36:07

问题


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!


回答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
  • insert/remove: shouldn't touch expansion state of unrelated nodes
  • valueChanged: shouldn't touch expansion state at all

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 :-)



来源:https://stackoverflow.com/questions/7386091/jtree-avoid-collapse-node-when-update-the-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!