KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > view > JobTreeCellRenderer


1 package org.oddjob.monitor.view;
2
3 import java.awt.Component JavaDoc;
4
5 import javax.swing.ImageIcon JavaDoc;
6 import javax.swing.JTree JavaDoc;
7 import javax.swing.tree.DefaultTreeCellRenderer JavaDoc;
8
9 import org.oddjob.images.IconTip;
10 import org.oddjob.monitor.model.JobTreeNode;
11
12 /**
13  * Display the icon in the job tree.
14  *
15  * @author Rob Gordon
16  */

17
18 public class JobTreeCellRenderer extends DefaultTreeCellRenderer JavaDoc {
19
20
21     /**
22      * Set the icon and tool tip.
23      */

24
25     public Component JavaDoc getTreeCellRendererComponent(
26                             JTree JavaDoc tree,
27                             Object JavaDoc value,
28                             boolean sel,
29                             boolean expanded,
30                             boolean leaf,
31                             int row,
32                             boolean hasFocus) {
33
34         super.getTreeCellRendererComponent(
35                             tree, value, sel,
36                             expanded, leaf, row,
37                             hasFocus);
38
39         JobTreeNode node = (JobTreeNode)value;
40
41         IconTip iconTip = node.getIcon();
42         if (iconTip != null) {
43             setIcon(new ImageIcon JavaDoc(iconTip.getImageData()));
44             setToolTipText(iconTip.getToolTip());
45         }
46         return this;
47     }
48
49 }
50
Popular Tags