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.
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.