..
> ..
>> new DefaultMutableTreeNode("THIS IS: string to show");
[quoted text clipped - 14 lines]
> HTH
> Andrew T.
That would work as a hack, but I suspect that you really want to use a
TreeCellRenderer to do the job properly. Not meaning to dismiss Andrew's
approach, which I use below, but because I suspect that you actually
want to do something a bit more complicated than you are actually asking.
For example, extending DefaultTreeCellRenderer, you could create your
nodes using
new DefaultMutableTreeNode("string to show");
and render it with
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row, boolean
hasFocus) {
JLable label = (JLabel) super.getTreeCellRendererComponent(tree,
value, selected, expanded, leaf, row, hasFocus);
label.setText("<html><body><b>THIS IS:</b> " + value.toString());
return label;
}
This is more of a building block to get you started building your own
more customised renderers.
Regards,
Rogan
giangiammy@gmail.com - 26 Jun 2006 11:09 GMT
Hi,
and thanks for the answers:
I tested both solution: the first (just put html in element node)
did not work (probably the Jtree widget do not support it - I
do not know)
Anyway with the second solution a defined MyRenderer and
works correctly: by now I just made it bold, but probably
I will add some other modification
thanks
giammy