aditya_gaur
aditya_gaur

Reputation: 3295

The working of model.insertNodeInto() function

I have a little confusion: Is the function insertNodeInto used to inserts only a single node and not its sub nodes? for example I have a code snippet as follows:

DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("topMost");
newNode.add(new DefaultMutableTreeNode("A node"));
newNode.add(new DefaultMutableTreeNode("B node"));
model.insertNodeInto(newNode,rootNode,0);

So will the above code add all the 3 nodes to the tree or just the topMost node?

Upvotes: 0

Views: 1314

Answers (1)

JB Nizet
JB Nizet

Reputation: 692121

The node, with all its children, is inserted in the model, as a simple test would have shown.

Upvotes: 2

Related Questions