Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a better way to test JTree node expanded or not?

Tags:

java

swing

jtree

I want to find a method like isNodeExpanded() to check if a given JTree node is expanded or not, but I can not find it.

I know I can do this by tracking the node expansion with the TreeExpansionListener. Is there a better way?

like image 446
waiting Avatar asked May 19 '10 00:05

waiting


1 Answers

JTree.java:

 /**
 * Returns true if the node identified by the path is currently expanded,
 * 
 * @param path  the <code>TreePath</code> specifying the node to check
 * @return false if any of the nodes in the node's path are collapsed, 
 *               true if all nodes in the path are expanded
 */
public boolean isExpanded(TreePath path);

Beautiful, JavaDoc :-)

The expanded state of a Node is not in the TreeModel but in the JTree.

like image 162
Pindatjuh Avatar answered Nov 10 '22 07:11

Pindatjuh