本文整理汇总了Java中javax.swing.JTree.collapsePath方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.collapsePath方法的具体用法?Java JTree.collapsePath怎么用?Java JTree.collapsePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.collapsePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandAll
import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAll(JTree tree, TreePath path, boolean expand) {
TreeNode node = (TreeNode) path.getLastPathComponent();
if (node.getChildCount() >= 0) {
Enumeration enumeration = node.children();
while (enumeration.hasMoreElements()) {
TreeNode n = (TreeNode) enumeration.nextElement();
TreePath p = path.pathByAddingChild(n);
expandAll(tree, p, expand);
}
}
if (expand) {
tree.expandPath(path);
} else {
tree.collapsePath(path);
}
}
示例2: closePaths
import javax.swing.JTree; //导入方法依赖的package包/类
public void closePaths(JTree tree, TreePath path) {
Object node = path.getLastPathComponent();
TreeModel model = tree.getModel();
if (model.isLeaf(node))
return;
int num = model.getChildCount(node);
for (int i = 0; i < num; i++)
closePaths(tree, path.pathByAddingChild(model.getChild(node, i)));
tree.collapsePath(path);
}
示例3: closePaths
import javax.swing.JTree; //导入方法依赖的package包/类
public static void closePaths(JTree tree, TreePath path) {
Object node = path.getLastPathComponent();
TreeModel model = tree.getModel();
if (model.isLeaf(node))
return;
int num = model.getChildCount(node);
for (int i = 0; i < num; i++)
closePaths(tree, path.pathByAddingChild(model.getChild(node, i)));
tree.collapsePath(path);
}