1. override the DefaultTreeNode, say it is call CellRender, to make it
aware of what type of node it is (iconed or not and which icon),
something to the effect of isOnline or isOffline will work.
2. override the cellrenderer (extend DefaultTreeCellRenderer) and
implement the following
public Component getTreeCellRendererComponent(JTree tree, Object
value,
boolean selected,
boolean expanded,
boolean leaf, int
row, boolean hasFocus) {}
in there do something to the effect of the following
if (((CellRender)value).isOnline)
setIcon(<your icon>
that should do it.
> Hi,
>
[quoted text clipped - 6 lines]
> An example would be greatly appreciated as I am no GUI expert here
> :).
Jim Sculley - 11 Feb 2004 22:57 GMT
> 1. override the DefaultTreeNode, say it is call CellRender, to make it
> aware of what type of node it is (iconed or not and which icon),
> something to the effect of isOnline or isOffline will work.
Often it is better to make your own TreeModel implementation so that you
can avoid all the TreeNode nonsense.
> 2. override the cellrenderer (extend DefaultTreeCellRenderer) and
> implement the following
[quoted text clipped - 10 lines]
>
> that should do it.
Generally, you first want to call the superclass implementation which
sets up a number of things such as highlighting, focus painting, etc.
super.getTreeCellRendererComponent(tree,value,sel,exp,leaf,row,hasFocus);
if (value instanceof SomeClassOfMine) {
setIcon(someIcon);
}
return this;
Jim S.

Signature
Remove my extraneous mandibular appendages to reply via email.