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
|
public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree,
value,
selected,
expanded,
leaf,
row,
hasFocus);
JLabel label = (JLabel)
super.getTreeCellRendererComponent(tree,
value,
selected,
expanded,
leaf,
row,
hasFocus);
ItemSelectionNode node = (ItemSelectionNode) value;
Action action = node.getAction();
if (action != null && action.isEnabled()) {
if (node.isHightlighted()) {
label.setForeground(HIGHLIGHTED_COLOR);
}
} else if (node.getChildCount()==0) {
label.setForeground(Color.LIGHT_GRAY);
} else {
DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent();
if (parent != null && parent.isRoot()) {
label.setForeground(new Color(5,121,175));
label.setFont(new Font("my font",Font.PLAIN,13));
}
}
label.setIcon(ImagePool.getIcon(node.getIconIndex()));
return label;
} |
Partager