I have made a JTree:
JTree tree = new JTree(orignalRootNode);
Then, I have demoted the root:
newRootNode.add(originalRootNode);
Now, real root node is newRootNode.
tree = new JTree(newRootNode);
But, aren't there more moderate ways for tree updating
than this brute-force?
It seems any method of tree model and tree node can't do
that.
Thomas Fritsch - 13 Jan 2005 12:54 GMT
> I have made a JTree:
>
[quoted text clipped - 13 lines]
> It seems any method of tree model and tree node can't do
> that.
If you have a DefaultTreeModel (or a subclass of it), you can simply
call its method
public void setRoot(TreeNode root);
for example like this:
((DefaultTreeModel) tree.getModel()).setRoot(newRootNode);
If you don't have a DefaultTreeModel, you could override its method
public Object getRoot();
of interface TreeModel and implement a setRoot method of your own.

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')