Example usage for javax.swing JTree collapsePath

List of usage examples for javax.swing JTree collapsePath

Introduction

In this page you can find the example usage for javax.swing JTree collapsePath.

Prototype

public void collapsePath(TreePath path) 

Source Link

Document

Ensures that the node identified by the specified path is collapsed and viewable.

Usage

From source file:com.pironet.tda.TDA.java

/**
 * expand or collapse all nodes of the specified tree
 *
 * @param catTree the tree to expand all/collapse all
 * @param parent  the parent to start with
 * @param expand  expand=true, collapse=false
 *//*from   w  w w  . java 2s .c  o m*/
private void expandAll(JTree catTree, TreePath parent, boolean expand) {
    // Traverse children
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {
        for (Enumeration e = node.children(); e.hasMoreElements();) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            expandAll(catTree, path, expand);
        }
    }

    if (parent.getPathCount() > 1) {
        // Expansion or collapse must be done bottom-up
        if (expand) {
            catTree.expandPath(parent);
        } else {
            catTree.collapsePath(parent);
        }
    }
}

From source file:org.geopublishing.atlasViewer.GpCoreUtil.java

private final static void expandAll(final JTree tree, final TreePath parent, final boolean expand) {
    // Traverse children
    final TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {
        for (final Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) {
            final TreeNode n = e.nextElement();
            final TreePath path = parent.pathByAddingChild(n);
            expandAll(tree, path, expand);
        }/*www. j  av  a2  s.c  o m*/
    }

    // Expansion or collapse must be done bottom-up
    if (expand) {
        tree.expandPath(parent);
    } else {
        tree.collapsePath(parent);
    }
}

From source file:org.nuclos.client.explorer.ExplorerNode.java

/**
 * collapse all children of this node//w  w  w .j  ava  2  s . c  o  m
 * @param tree
 */
public void collapseAllChildren(JTree tree) {
    for (int i = getChildCount() - 1; i >= 0; i--) {
        tree.collapsePath(new TreePath(((DefaultMutableTreeNode) this.getChildAt(i)).getPath()));
    }
}