Hello I have question regarding saving expansion state when change DefaultTreeModel. Currently I have a jTree which looks like this:
If I select an item from the left JList and select a TestGr from right Jtree and click on Add Test Case button it will add the selected items to the DefaultTreeModel. Doing this will collapse the tree:
I would like to somehow save the previous expansion state and just update the tree to show the newly added element like this for example:
My goal is to save the previously expanded state which ever that may be and when I add elements to TestGr, everything which was expanded, should stay expanded and update itself with the new element. Does anyone have any idea how might i achieve this? I have tried the solution from store state/expanded nodes of a jtree for restoring state but it's not suitable because when i update my DefaultTreeModel, the row count gets updated too and it expands the wrong rows. Thank you in advance for a hint.