The SampleTree example in Swing shows one way to implement lazy loading.
-- Ron
Theron Kousek wrote:
>
> I need to "recursively" create a copy(need to create a brand new physical
> copy) of a tree node and all of it's children (which includes grand children
> and great grandchildren, etc..)...
>
> Can someone tell me what methods I should be looking at in order to
> accomplish this?
>
> I've been looking at the Enumeration process to enumerate thru all of the
> nodes and descendents but am a little confused.
>
> Regards,
> Theron K
If you pass it a root node, you'll get back a complete
copy of it and its children. Christian (who posts here ofter)
helped me with this a while back
robert
Matt. 6:33
public DefaultMutableTreeNode clone(DefaultMutableTreeNode node)
{
Whatever w = node.userObject(); // skip these lines if you don't
Whatever wClone = w.clone(); // want to clone the user objects
DefaultMutableTreeNode clone = new DefaultMutableTreeNode(wClone);
for (int len = node.getChildCount(), i = 0; i < len; i++)
clone.add(clone(node.getChildAt(i))); // recursive call
return clone;
}
(easily adapted if you do not use DefaultMutableTreeNodes).
Followup-to set.
Christian