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

1

9

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?

Kenyettakenyon answered 19/5, 2010 at 0:38 Comment(0)
A
14

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.

Ardithardme answered 19/5, 2010 at 1:25 Comment(1)
Thanks, I overlook the JTree's JavaDoc :-)Kenyettakenyon

© 2022 - 2024 — McMap. All rights reserved.