java - Update selectionPaths in a JTree when the model updates -


i have jtree custom objects , custom model. @ point, select node , when happens, update tree new retrieved data. when happens go trough tree find selected node , substitute new 1 (up date). when find it, remove old node parent, add new 1 in positions , call nodechanged(newnode). tree updates ok, new node appears there updated content.

the problem when coming tree update, selection paths have not been updated, when use method getselectionpaths(), returning path (if 1 node selected) corresponds old node removed tree.

how can update selection paths new updated model?

you create new treepath , call setselectedpath new path. however, better to, instead of removing node, make mutable , update node. way tree model isn't changing , selection path wouldn't changed.

you'd need fire appropriate event (node changed, instead of node removed/added etc).


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -