| Author |
Showing PLUS sign(tree expansion) even if child is not present
|
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 63
|
|
Hi,
I want to create Tree in which there will be single Parent node and multiple child nodes. I want to create these child node after user click on PLUS sign which is used for Tree Expansion. I can add nodes in JTree using TreeExpansionListener's method treeExpanded. But I have problem in showing PLUS sign with Parent Node. As if childs are not present this sign does not come, it comes after adding first child. So I am thinking of adding dummy child to get this PLUS sign, when user clicks it I will remove dummy child and will add actual childs.
Is there any other better way by which I can show PLUS sign(tree expansion icon) at parent node even if parent does not have any child.
Thanks,
Sham
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
|
That means that your TreeNode object is returning "false" when its "isLeaf()" method is called. That's what you have to fix.
|
 |
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 63
|
|
Thanks Paul, now I am able to get PLUS sign even if childs are not present under parent node.
Now I want to create child nodes when user clicks PLUS sign. Which event get generated in this case, I tried TreeExpansionLIstener and TreeWillEXpandListener.
Do I need to simply catch mouse event?
|
 |
Tarun Bolla
Ranch Hand
Joined: Jun 20, 2011
Posts: 85
|
|
It seems you are referring to Lazy Loading
http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html
|
 |
 |
|
|
subject: Showing PLUS sign(tree expansion) even if child is not present
|
|
|