Cloning nodes in JTree
Posted on 2001-06-13
Hi I have a basic tree.
Now I want to create Tree A and Tree B which will
have the nodes of basic tree and some additional
I get the nodes of the basic tree by
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)basicTree. getModel().getRoot();
Enumeration enum = rootNode.children();
childCount = rootNode.getChildCount();
The problem is once I add these nodes to Tree A
I cannot add these nodes to Tree B.
infact after adding the nodes to Tree A
if I do : childCount = rootNode.getChildCount();
I get childCount = 0;
I dont know how the basic tree gets affected
I think I have to do deep cloning and then
work on the cloned node.
If I can see come code snippet of deep cloning
a node . it will be helpful
Structure of tree example:
fab ---- root node
each of the children name, address, city
have multiple nodes.
I want to copy all the children of
the root node to multiple trees.