Java JTree Path loadExpansionState(JTree tree, Enumeration expansionState)

Here you can find the source of loadExpansionState(JTree tree, Enumeration expansionState)

Description

Restore the expansion state of a JTree.

License

Apache License

Parameter

Parameter Description
tree a parameter
expansionState an Enumeration of expansion state. You can get it using #saveExpansionState(javax.swing.JTree) .

Declaration

public static void loadExpansionState(JTree tree, Enumeration<TreePath> expansionState) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Enumeration;

import javax.swing.JTree;

import javax.swing.tree.TreePath;

public class Main {
    /**//  w w w .j  a va 2 s  . c o  m
     * Restore the expansion state of a JTree.
     * Note: this will NOT work for most use-cases in IPSmallJava as data-model of tree is reset after most tasks.
     *
     * @param tree
     * @param expansionState an Enumeration of expansion state. You can get it using {@link #saveExpansionState(javax.swing.JTree)}.
     */
    public static void loadExpansionState(JTree tree, Enumeration<TreePath> expansionState) {
        if (expansionState != null) {
            while (expansionState.hasMoreElements()) {
                TreePath treePath = (TreePath) expansionState.nextElement();
                tree.expandPath(treePath);

            }
        }
    }
}

Related

  1. isDescendant(TreePath path1, final TreePath path2)
  2. isFile(TreePath path)
  3. isSource(TreePath path)
  4. isTreePathContainedInExpansionState(TreePath treePath, ArrayList expansionStateStrings)
  5. lastPathComponents(TreePath[] paths)
  6. makeLocalFilePath(TreePath treePath)
  7. makeTreePath(TreeNode treeNode)
  8. pathByAddingChildAsStr(TreePath currPath, String child)
  9. pathContains(TreePath[] paths, Class clazz)