问题
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