1 package org.catacomb.druid.swing;
2
3
4
5 import java.awt.Component;
6
7 import javax.swing.Icon;
8 import javax.swing.JTree;
9 import javax.swing.tree.DefaultTreeCellRenderer;
10
11 import org.catacomb.icon.IconLoader;
12
13
14
15
16 public class TCRenderer extends DefaultTreeCellRenderer {
17 static final long serialVersionUID = 1001;
18
19 static Icon leafIcon;
20 static Icon closedIcon;
21 static Icon openIcon;
22
23
24 static {
25 leafIcon = IconLoader.createImageIcon("leaf.gif");
26 closedIcon = IconLoader.createImageIcon("closed.gif");
27 openIcon = IconLoader.createImageIcon("open.gif");
28 }
29
30
31
32
33
34 public Component getTreeCellRendererComponent(JTree tree,
35 Object value,
36 boolean sel,
37 boolean expanded,
38 boolean leaf,
39 int row,
40 boolean lhasFocus) {
41
42 super.getTreeCellRendererComponent(tree, value, sel,expanded, leaf, row, lhasFocus);
43
44 if (leaf) {
45 setIcon(leafIcon);
46 } else if (expanded) {
47 setIcon(openIcon);
48 } else {
49 setIcon(closedIcon);
50 }
51
52
53 return this;
54 }
55
56
57 }