public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
if(value instanceof ContactGroup) {
ContactGroup cg = (ContactGroup)value;
Component c = super.getTreeCellRendererComponent(tree, cg.getName(), selected, expanded, leaf, row, hasFocus);
return c;
} else if(value instanceof Contact) {
Contact contact =(Contact)value;
Component c = super.getTreeCellRendererComponent(tree, contact.getName(), selected, expanded, leaf, row, hasFocus);
return c;
} else if(value instanceof ContactMethod) {
ContactMethod cm = (ContactMethod) value;
Component c = super.getTreeCellRendererComponent(tree, cm.toString(), selected, expanded, leaf, row, hasFocus);
Icon icon = cm.getIcon();
if(icon != null) {
setIcon(icon);
}
return c;
} else {
return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
}
Gets a Component to render a specified object. This implementation treats ContactGroups, Contacts, and ContactMethods specially, and sends all others to the superclass. |