1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.vci.client.portal.NewNewUI.Export;
 
import java.awt.Component;
 
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
 
import com.vci.client.portal.NewNewUI.Export.BaseExportNode;
 
 
public class ExportTreeCellRenderer extends DefaultTreeCellRenderer {
 
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    // 设置节点样式
    public ExportTreeCellRenderer() {
        super();
    }
 
    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value,
            boolean sel, boolean expanded, boolean leaf, int row,
            boolean hasFocus) {
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                row, hasFocus);
        //设置节点icon
        Icon closeIcon = this.getDefaultClosedIcon();
        Icon leafIcon = this.getDefaultLeafIcon();
        Icon openIcon = this.getDefaultOpenIcon();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
        if ( node.getUserObject() instanceof BaseExportNode) {
            BaseExportNode baseExportNode = (BaseExportNode) node.getUserObject();
            if (baseExportNode.getLeaf() == BaseExportNode.IS_NOT_LEAF) {
                if(expanded){
                    this.setIcon(openIcon);
                }else{
                    this.setIcon(closeIcon);
                }
                
                
            }else{
                if (baseExportNode.getLeaf() == BaseExportNode.IS_LEAF) {
                    this.setIcon(leafIcon);
                }    
            }
            this.setForeground(baseExportNode.getFontColor());
            if (baseExportNode.getLeaf() == BaseExportNode.IS_A_Message) {
                this.setIcon(null);
            }    
        }
          
         
       
        return this;
    }
 
}