Java JTree saveExpansionStateStrings(JTree tree)

Here you can find the source of saveExpansionStateStrings(JTree tree)

Description

save Expansion State Strings

License

Apache License

Declaration

public static ArrayList<String> saveExpansionStateStrings(JTree tree) 

Method Source Code

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

import java.util.ArrayList;

import java.util.Enumeration;

import javax.swing.JTree;

import javax.swing.tree.TreePath;

public class Main {
    public static ArrayList<String> saveExpansionStateStrings(JTree tree) {
        ArrayList<String> result = new ArrayList<String>();
        Enumeration<TreePath> expansionState = tree.getExpandedDescendants(new TreePath(tree.getModel().getRoot()));
        if (expansionState != null) {
            while (expansionState.hasMoreElements()) {
                TreePath treePath = (TreePath) expansionState.nextElement();
                result.add(treePath.toString());
            }//  ww  w .j a v  a 2 s. c o  m
        }
        return result;
    }
}

Related

  1. RemoveAll(JTree tree)
  2. repaintSelection(JTree tree)
  3. restoreExpanstionState(JTree tree, int row, String expansionState)
  4. revalidateTree(java.awt.Component c)
  5. saveExpansionState(JTree tree)
  6. saveTreeSelection(JTree tree)
  7. scrollToSelection(JTree tree)
  8. scrollTreeToSelectedRow(final JTree tree)
  9. setComponentTreeEnabled(Component c, boolean enabled)