Tree Customizations
To change the look of our tree, we change the DefaultTreeCellRenderer:
DefaultTreeCellRenderer renderer =
new DefaultTreeCellRenderer();
renderer.setLeafIcon(new ImageIcon
tree.setCellRenderer(renderer);
UIManager.put("Tree.leafIcon",
new ImageIcon(”foo.gif"));
UIManager.put("Tree.openIcon",
new ImageIcon(”bar.gif"));
UIManager.put("Tree.closedIcon",
new ImageIcon(”baz.gif"));
UIManager.put("Tree.expandedIcon",
new ImageIcon(”frob.gif"));
UIManager.put("Tree.collapsedIcon",
new ImageIcon(”qux.gif"));
We can also directly change the Tree through the UIManager: