• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems you are referring to Lazy Loading
http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic