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.
我想找到像isNodeExpanded()这样的方法来检查给定的JTree节点是否被扩展,但我找不到它。
I know I can do this by tracking the node expansion with the TreeExpansionListener. Is there a better way?
我知道我可以通过使用TreeExpansionListener跟踪节点扩展来实现此目的。有没有更好的办法?
1 个解决方案
#1
13
JTree.java:
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 :-)
美丽,JavaDoc :-)
The expanded state of a Node is not in the TreeModel
but in the JTree
.
Node的扩展状态不在TreeModel中,而是在JTree中。
#1
13
JTree.java:
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 :-)
美丽,JavaDoc :-)
The expanded state of a Node is not in the TreeModel
but in the JTree
.
Node的扩展状态不在TreeModel中,而是在JTree中。