posted 21 years ago
Ok, this question has been asked mutliple times in different varients and forms. So here goes my version because after searching Javaranch and google for 2 days, I can't seem to find a valid answer.
I have a JTree. I build the Tree through a DefaultTreeModel which I have over-ridden. All my values in the Tree come from a databse. Each leaf node is a CustomObject I have created which holds all the relevent information about the leaf object. That's all fine and dandy.
Now, there are various operations that can be performed on the tree leaf objects. Any one of these operations causes the database information to change and the location of the leaf on the tree to change.
Since this app runs on several PC's, the easiest way for me to pick up all the new data is to reload the Tree Model. The problem is that this collapses my Tree. I need the tree to stay expanded to the degree that the user had it before changing information. But the tree also needs to reflect to moves and changes of the leaf nodes.
I tried using a TreePath to store the expanded state of the Tree, but it saves the expanded state with the leaf nodes in their original places instead of them being moved.
Any ideas, suggestions, or comments are welcome to help me solve my problem.
Thanks.