Results 1 to 2 of 2
Thread: Keep a JTree from collapsing
- 10-31-2011, 11:50 PM #1Member
- Join Date
- Jul 2010
- Lima, Peru
- Rep Power
Keep a JTree from collapsing
I don't know if this is a method from the DefaultMutableTreeNode or from the JTree... But whenever I double click a node, it collapses.
I don't want the double click to collapse the nodes. I want the tree to be always expanded.
More specifically, I want the ROOT node to be always expanded, even if the user double clicks on it (don't want it to collapse).
How do I do this?
I have tried "tree.expandRow(0);" and calling it at the very end of the valueChanged() event method. However, it seems not to work. The tree still collapses when I double click on it.
- 11-01-2011, 08:12 AM #2
Re: Keep a JTree from collapsing
Read the API for JTree and note the various listeners that can be added via the addXxxListener(...) methods. One of the listeners is capable of providing the functionality you seek, and its API has a link to the Oracle tutorial that describes accurately, with a code sample, how to prevent a node from expanding.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By AsylumDreams in forum Advanced JavaReplies: 2Last Post: 01-14-2010, 04:04 AM
- By Melki in forum AWT / SwingReplies: 8Last Post: 07-09-2009, 11:59 AM
- By Hadley in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 01-30-2009, 11:18 PM
- By roohja in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-05-2009, 07:15 AM
- By rudbls in forum New To JavaReplies: 3Last Post: 12-15-2007, 11:19 PM