KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bluecubs > xinco > client > XincoTreeCellRenderer


1 /**
2  *Copyright 2004 blueCubs.com
3  *
4  *Licensed under the Apache License, Version 2.0 (the "License");
5  *you may not use this file except in compliance with the License.
6  *You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *Unless required by applicable law or agreed to in writing, software
11  *distributed under the License is distributed on an "AS IS" BASIS,
12  *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *See the License for the specific language governing permissions and
14  *limitations under the License.
15  *
16  *************************************************************
17  * This project supports the blueCubs vision of giving back
18  * to the community in exchange for free software!
19  * More information on: http://www.bluecubs.org
20  *************************************************************
21  *
22  * Name: XincoTreeCellRenderer
23  *
24  * Description: cell renderer on client side
25  *
26  * Original Author: Alexander Manes
27  * Date: 2004
28  *
29  * Modifications:
30  *
31  * Who? When? What?
32  * - - -
33  *
34  *************************************************************
35  */

36
37 package com.bluecubs.xinco.client;
38
39 import java.awt.Component JavaDoc;
40 import javax.swing.*;
41 import javax.swing.tree.*;
42
43 import com.bluecubs.xinco.core.*;
44
45 class XincoTreeCellRenderer extends DefaultTreeCellRenderer {
46
47     public XincoTreeCellRenderer() {
48     }
49
50     public Component JavaDoc getTreeCellRendererComponent(
51                         JTree tree,
52                         Object JavaDoc value,
53                         boolean sel,
54                         boolean expanded,
55                         boolean leaf,
56                         int row,
57                         boolean hasFocus) {
58
59         super.getTreeCellRendererComponent(
60                         tree, value, sel,
61                         expanded, leaf, row,
62                         hasFocus);
63                         
64         if (leaf && isFolder(value)) {
65             setIcon(getClosedIcon());
66             setToolTipText("");
67         } else {
68             setToolTipText(null); //no tool tip
69
}
70
71         return this;
72     }
73
74     protected boolean isFolder(Object JavaDoc value) {
75         DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
76         if(node.getUserObject().getClass() == XincoCoreNode.class) {
77             return true;
78         } else {
79             return false;
80         }
81     }
82 }
Popular Tags