From: stormreaver
Written: 2010-04-26 10:42:32.963111
Subject: Forcing JTree to Redraw After Adding/Deleting A Node

You've added a node to, or removed a node from, a JTree, and now need to make the JTree redraw itself to reflect the changes you've made. For efficiency reasons, the JTree does not automatically update itself whenever a change is made. Just think about what would happen to responsiveness if the JTree redrew itself after each of a thousand changes, for example.

After you've made all your changes to the JTree, call
[your tree model].nodeStructureChanged(parent_node);

parent_node is the node containing any node you have changed. For simplicity, you can make parent_node the tree's root node. This will redraw the entire tree with parent_node expanded to show its children, though I haven't experimented enough yet to know whether or not it expands all child nodes.
You must register an account before you can reply.