首页 > 其他 > 详细

利用哈希表(Hashtable)的数据来建立树结构

时间:2016-03-05 21:47:38      阅读:277      评论:0      收藏:0      [点我收藏+]

/*利用哈希表的数量来建立树结构*/

class TreesDemo extends JPanel{

  public TreesDemo(){

    JFrame f = new JFrame("Hashtable");

    Hashtable hashtable1 = new Hashtable();

    Hashtable hashtable2 = new Hashtable();

    String [] s1 = {"SWLT","JavaAHZ","WSSD"};

    String [] s2 = {"GSWJ","SRWJ","lWWJ"};

    String [] s3 = {"BDCPc"."BDCPd","BDCPe"};

    hashtable1.put("ZM",hashtable2);

    hashtable2.put("SCJ",s1);

    hashtable2.put("WDGWB",s2);

    hashtable2.put("WDDN",s3);

    JTree jTree = new JTree(hashtable1);

    JScrollPane scrollPane = new JScrollPane();

    scrollPane.setViewportView(jTree);

    Container con = f.getContentPanel();

    con.add(scrollPane);

    f.setSize(300,200);

    f.setLoction(500,100);

    f.setVisible(true);

    f.addWindowListener(new WindowAdapter(){

      public void windowClosing(WindowEvent e){

        System.exit(0);

      }

    });

  }

}

public class Example{

  public static void main(String[] args){

    new TreesDemo();

  }

}

 

利用哈希表(Hashtable)的数据来建立树结构

原文:http://www.cnblogs.com/HeeKo/p/5245857.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!