aspose file tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Showing PLUS sign(tree expansion) even if child is not present Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Showing PLUS sign(tree expansion) even if child is not present" Watch "Showing PLUS sign(tree expansion) even if child is not present" New topic
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
 
IntelliJ Java IDE
 
subject: Showing PLUS sign(tree expansion) even if child is not present
 
Threads others viewed
Tree structure retrieval from Database
show plus sign initially for nodes without children
JTree, adding and removing nodes contained in a master tree
Sorting JTree Nodes alphabetically
i have a leaf node - it shows expanded handles
developer file tools