01: package vicazh.hyperpool.stream.net.http;
02:
03: import javax.swing.*;
04: import javax.swing.tree.*;
05: import java.awt.*;
06:
07: /**
08: * The explorer tree renderer
09: *
10: * @author Victor Zhigunov
11: * @version 0.3.6
12: */
13: public class IExplorerRenderer extends DefaultTreeCellRenderer {
14: private Icon iconRoot;
15:
16: private Icon iconServer;
17:
18: private Icon iconFolder;
19:
20: IExplorerRenderer() {
21: iconRoot = UIManager.getIcon("earthIcon");
22: iconServer = UIManager.getIcon("serverIcon");
23: iconFolder = UIManager.getIcon("folderIcon");
24: }
25:
26: public Component getTreeCellRendererComponent(JTree tree,
27: Object value, boolean sel, boolean expanded, boolean leaf,
28: int row, boolean hasFocus) {
29: super .getTreeCellRendererComponent(tree, value, sel, expanded,
30: leaf, row, hasFocus);
31: Icon editingIcon = null;
32: switch (((DefaultMutableTreeNode) value).getLevel()) {
33: case 0:
34: editingIcon = iconRoot;
35: setFont(getFont().deriveFont(Font.BOLD));
36: break;
37: case 1:
38: editingIcon = iconServer;
39: setFont(getFont().deriveFont(Font.ITALIC));
40: break;
41: default:
42: editingIcon = iconFolder;
43: setFont(getFont().deriveFont(Font.PLAIN));
44: }
45: if (editingIcon != null) {
46: setIcon(editingIcon);
47: setDisabledIcon(editingIcon);
48: }
49: return this;
50: }
51: }
|