Hi anloleo,
Although david_d is right, I understand that you want to set the root in a pre-existing JTree.
You are also right, JTree itself has no method to do this. That is because JTree is not where the data is stored. This is in the TreeModel. TreeModel is just an "interface", so it contains no implementation. Since you are using defaults, you should actually have a "DefaultTreeModel" within your JTree.
You can get this using:
DefaultTreeModel theModel = (DefaultTreeModel)myTree.g
If you have:
DefaultMutableTreeNode theRootNode;
you can then do:
theModel.setRoot(theRootNo
Thanx.
Jim.
Main Topics
Browse All Topics





by: david_dPosted on 2000-10-16 at 09:40:10ID: 4754567
Hi,
ect);
The best thing to do would be:
DefaultMutableTreeNode dMTN = new DefaultMutableTreeNode();
JTree tree = new JTree(dMTN);
dMTN = new DefaultMutableTreeNode(Obj
This places a new object into the root defaultMutableTreeNode.
The first line of code makes the JTree have no text next to the folder or file icon.
Cheers
David