The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing.tree  [15 examples]

e1019. Creating a JTree Component

This 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);

 Related Examples
e1020. Changing and Removing the Default Icons in a JTree Component

See also: Events    Layout    Node Expansion    Nodes    Selections   


© 2002 Addison-Wesley.