• Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing PLUS sign(tree expansion) even if child is not present

 
Sham Phadtale
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21875
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems you are referring to Lazy Loading
http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!