I need to dynamically change the display information of tree nodes (e.g. node text), and then refresh the entire JTree so that my changes are displayed.
DefaultTreeModel has lots of useful methods that I could use to refresh the tree (e.g. reload()), however, there is no guarantee that the JTree will be using DefaultTreeModel.
Is there a way to refresh the tree without using DefaultTreeModel?
I am temporarily using the following code for the refresh:
// Note the currently selected path so that it can be
// restored after the tree is refreshed.
TreePath selectedPath = tree.getSelectionPath();
// Do the "refresh".
// The selection path will now be set to rootPath.
// Restore the old selection path.
But this will fire unwanted TreeSelectionEvents, so I would prefer another solution.