Creating a JTree Component - Java Swing

Java examples for Swing:JTree

Description

Creating a JTree Component

Demo Code

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

public class Main {
  public void main() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root Label");
    root.add(new DefaultMutableTreeNode("Node Label"));

    JTree tree = new JTree(root);
  }/*from  ww  w  .  ja v a 2 s .  c  om*/
}

Related Tutorials