import java.awt.BorderLayout;
import java.util.Hashtable;
import java.util.Properties;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
public class MainClass {
public static void main(final String args[]) {
JFrame frame = new JFrame("DynamicUtilTreeNode Hashtable");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
Hashtable<Object, Object> hashtable = new Hashtable<Object, Object>();
hashtable.put("A", args);
hashtable.put("B", new String[] { "a", "b", "c" });
Hashtable<Object, Object> innerHashtable = new Hashtable<Object, Object>();
Properties props = System.getProperties();
innerHashtable.put(props, props);
hashtable.put("C", innerHashtable);
JTree.DynamicUtilTreeNode.createChildren(root, hashtable);
JTree tree = new JTree(root);
JScrollPane scrollPane = new JScrollPane(tree);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
|