JTree.DynamicUtilTreeNode: createChildren(DefaultMutableTreeNode parent, Object children)
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);
}
}
Related examples in the same category
1. | Tree.closedIcon | | |
2. | Tree.collapsedIcon | | |
3. | Tree.expandedIcon | | |
4. | Tree.leafIcon | | |
5. | Tree.openIcon | | |
6. | new JTree() | | |
7. | new JTree(TreeNode root) | | |
8. | new JTree(Vector vector) | | |
9. | JTree: addTreeSelectionListener(TreeSelectionListener tsl) | | |
10. | JTree: addTreeWillExpandListener(TreeWillExpandListener tel) | | |
11. | JTree: convertValueToText(Object v,boolean s,boolean e,boolean l,int r,boolean h) | | |
12. | JTree: getCellRenderer() | | |
13. | JTree: getLeadSelectionRow() | | |
14. | JTree: getMaxSelectionRow() | | |
15. | JTree: getMinSelectionRow() | | |
16. | JTree: getNextMatch(String prefix, int startingRow, Bias bias) | | |
17. | JTree: getPathForLocation(int x, int y) | | |
18. | JTree: getRowHeight() | | |
19. | JTree: getSelectionRows() | | |
20. | JTree: putClientProperty('JTree.lineStyle', 'None') | | |
21. | JTree: setAutoscrolls(boolean b) | | |
22. | JTree: setCellEditor(TreeCellEditor editor) | | |
23. | JTree: setExpandedState(TreePath path, boolean state) | | |
24. | JTree: setRowHeight(int rowHeight) | | |
25. | JTree: setTransferHandler(TransferHandler newHandler) (Drag and drop files from file explore) | | |