JTree - renderer

When i expand a jtree node, i am populating the content in runtime. I use model.insertNodeInto() method to insert the nodes. I have a dummy node in the first position so that i can get a +, so that i can expand the jtree node. I am changing the first dummy node to a node i want using model.valueForPathChanged() method. Everything works fine. I have a renderer attached. model.insertNodeInto() calls the getTreeCellRendererComponent() method successfully. But model.valueForPathChanged() is not calling the getTreeCellRendererComponent() by default.

My questions are:

1. Can i call the renderer forcefully for valueForPathChanged? If so, how?

2. Is there a easy way to get + for a node, even though the node has no child? i.e a leaf should have + , so that i can expand.

3. I tried deleting the first node, and insert a new node in first position. But removeNodeFromParent is calling model.reload() which is causing collapse of my node.

[969 byte] By [ganeshaa8a] at [2007-11-26 13:58:18]
# 1
Best thing to do is implementing your own tree mobel or tree node.It has a method that should retun the number of childs a node has. When it return a value greater than zero you will get the + sign.
LRMKa at 2007-7-8 1:38:34 > top of Java-index,Desktop,Core GUI APIs...
# 2

> Best thing to do is implementing your own tree mobel

> or tree node.

> It has a method that should retun the number of

> childs a node has. When it return a value greater

> than zero you will get the + sign.

I am implementing my own model. but can you help with the exact method to overload and return a value greater than 0. ?

Thanks.

ganeshaa8a at 2007-7-8 1:38:34 > top of Java-index,Desktop,Core GUI APIs...
# 3

DefaultTreeModel treeModel = new DefaultTreeModel(root){public boolean isLeaf(Object node){return false;}};

tree.setModel(treeModel);

root is the root node and tree the JTree.

you will have the sign to expand the node even if it's a leaf.

ProZa at 2007-7-8 1:38:34 > top of Java-index,Desktop,Core GUI APIs...
# 4

> > DefaultTreeModel treeModel = new

> DefaultTreeModel(root){public boolean isLeaf(Object

> node){return false;}};

> tree.setModel(treeModel);

>

>

> root is the root node and tree the JTree.

> you will have the sign to expand the node even if

> it's a leaf.

Oh... It worked. Thanks a lot. ;)

ganeshaa8a at 2007-7-8 1:38:35 > top of Java-index,Desktop,Core GUI APIs...
# 5
Why 1DD is remaining ? ;)
ProZa at 2007-7-8 1:38:35 > top of Java-index,Desktop,Core GUI APIs...
# 6
Its for me... ;).. This Forum is really good one.. for anyt questions in java world we have an answer here... Thanks to all...
ganeshaa8a at 2007-7-8 1:38:35 > top of Java-index,Desktop,Core GUI APIs...