Creating a Tree 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);