码迷,mamicode.com
首页 > 其他好文 > 详细

建立一个系统默认的简单树结构

时间:2016-03-05 21:58:25      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

/*最简单的JTree示例*/

class MyTree extends JFrame{

  public MyTree(String s){

    super(s);

    Container con = new getContentPane();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("d:\\")

    DefaultMutableTreeNode t1 = new DefultMutableTreeNode("BFZL");

    DefaultMutableTreeNode t2 = new DefaultMutableTreeNode("JavaXX");

    DefaultMutableTreeNode t1_1 = new DefaultMutableTreeNode("SWJHTZ");

    DefaultMutableTreeNode t1_2 = new DefaultMutableTreeNode("WLYJ");

    DefaultMutableTreeNode t2_1 = new DefaultMutableTreeNode("SPJC");

    DefaultMutableTreeNode t2_2 = new DefaultMutableTreeNode("Java 3D");

    JTree jTree = new JTree(root);

    root.add(t1);root.add(t2);

    t1.add(t1_1);t1.add(t1_2);

    t2.add(t2_1);t2.add(t2_2);

    JScrollPane scrollPane = new JScrollPane(jTree);

    con.add(scrollPane);

    setSize(200,300);

    setLoction(500,100);

    setVisible(true);

    vildate();

    addWindowListener(new WindowAdapter(){

      public void windowClosing(WindowEvent e){

        System.exit(0);

      }

    });

  }

}

public class Example{

  public static void main(String[] args){

    new Mytree("利用TreeNode构造树");

  }

}

 

建立一个系统默认的简单树结构

标签:

原文地址:http://www.cnblogs.com/HeeKo/p/5245799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!