I have created a jtree with the root node "RootNode" and some other nodes like "Node1","Node2", Node3".
After creation of tree I want to rename the rootnode or any other node by manually. We can rename the node dynamically by using the method
jtee.setEditable(true);
But I want to change the name in manualy by the code level
like
someMethod(Arg1 oldNodeName,Arg2 newNodeName)
Is there any way to do this?
Assuming you are using a DefaultMutableTreeNode you could just change the UserObject (whose toString() method is what is used to display the node name) by calling: setUserObject()
on the node you want to change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With