public java.awt.Component | getTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
setText(value.toString());
if (selected) {
setOpaque(true);
}
else {
setOpaque(false);
}
// Try to find an IconAndTipCarrier version of the current node.
IconAndTipCarrier itc = null;
if (value instanceof DefaultMutableTreeNode) {
Object uo = ((DefaultMutableTreeNode)value).getUserObject();
if (uo instanceof IconAndTipCarrier) {
itc = (IconAndTipCarrier)uo;
}
}
else if (value instanceof IconAndTipCarrier) {
itc = (IconAndTipCarrier)value;
}
if ((itc != null) && (itc.getIcon() != null)) {
// Great! Use itc's values to customize this label
setIcon(itc.getIcon());
tipText = itc.getToolTipText();
}
else {
// Hmmm, nothing available, so rely on the defaults.
tipText = " ";
if (expanded) {
setIcon(openIcon);
}
else if (leaf) {
setIcon(leafIcon);
}
else {
setIcon(closedIcon);
}
}
return this;
|