tree icon is getting displayed even if there are no childrens

Is there any other way by which the tree icon can be made to display

without the usage ofsetAllowsChildren() method ofjavax.swing.tree.DefaultMutableTreeNode., bcos if i set

setAllowsChildren(true) for a particular node then the tree icon appears, irrespective of it having any children.

How do i perform necessary validation so that the icon is set only if the particular node has children?

Thanks in advance

[464 byte] By [jaaya] at [2007-10-2 16:55:54]
# 1

You could write your own TreeCellRenderer to show empty nodes that

are capable of having children. Sun's Tutorial has an example here:

http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

(in the section "Customizing a Tree's Display").

You should note that typical usage (for example in file system viewers)

is for things that could have children (folders/directories) to be

drawn the same way whether or not they do, in fact, have children. But

you are free to change this convention, of course.

If you have difficulty implementing this the Swing forum would be the

best place to post your code.

pbrockway2a at 2007-7-13 18:08:32 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks for help.But in my application everything is already done, except for the fact thattree icon is displayed even when there is no child node.What may be the problem.?Thanks in advance
jaaya at 2007-7-13 18:08:32 > top of Java-index,Java Essentials,New To Java...
# 3
Thanks everybody for ur effort.Actually it is a java bug. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6350815
jaaya at 2007-7-13 18:08:32 > top of Java-index,Java Essentials,New To Java...
# 4
Ah, I see - it's the handles on the icon that are misleading. Thanks forpointing this out.
pbrockway2a at 2007-7-13 18:08:32 > top of Java-index,Java Essentials,New To Java...