![]() |
The Java Developers Almanac 1.4 |
|
e1019. Creating a JTree ComponentThis example creates a tree component with a root node and a child of the root node. You build the tree hierarchy by adding nodes to nodes. DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root Label");
root.add(new DefaultMutableTreeNode("Node Label"));
JTree tree = new JTree(root);
© 2002 Addison-Wesley. |