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

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

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

  }

}

 

posted @ 2016-03-05 20:59  嘿壳  阅读(484)  评论(0编辑  收藏  举报