有没有更好的方法来测试JTree节点是否扩展?

wai*_*ing 7 java swing jtree

我想找到像isNodeExpanded()的方法来检查,如果给定的JTree节点展开或没有,但我不能找到它.

我知道我可以通过使用TreeExpansionListener跟踪节点扩展来实现此目的.有没有更好的办法?

Pin*_*juh 13

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);
Run Code Online (Sandbox Code Playgroud)

美丽,JavaDoc :-)

节点的展开状态是不是TreeModel,但在JTree.