Java Code Examples for javax.swing.JTree#getExpandedDescendants()

The following examples show how to use javax.swing.JTree#getExpandedDescendants() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeUtils.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static public Collection<TreePath> getExpandedPaths(JTree tree) {
  Collection<TreePath> set = new TreeSet<TreePath>(tpLengthComparator);
  TreePath root = new TreePath(tree.getModel().getRoot());
  if(root != null) {
    for(Enumeration<TreePath> e = tree.getExpandedDescendants(root); e != null && e.hasMoreElements(); ) {
      TreePath tp = e.nextElement();
      set.add(tp);
    }
  }
  return set;
}
 
Example 2
Source File: TreeUtil.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Get a copy of the list of expanded tree paths of a tree.
 */
public static TreePath[] getExpandedPaths(JTree tree) {
    ArrayList<TreePath> expandedPaths = new ArrayList<TreePath>();
    TreePath rootPath = new TreePath(tree.getModel().getRoot());
    Enumeration enumeration = tree.getExpandedDescendants(rootPath);
    if (enumeration != null) {
        while (enumeration.hasMoreElements()) {
            expandedPaths.add((TreePath)enumeration.nextElement());
        }
    }
    TreePath[] array = new TreePath[expandedPaths.size()];
    expandedPaths.toArray(array);
    return array;
}
 
Example 3
Source File: ProfilerTreeTable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static UIState getUIState(JTree tree) {
    TreePath[] selectedPaths = tree.getSelectionPaths();
    TreePath rootPath = new TreePath(tree.getModel().getRoot());
    Enumeration<TreePath> expandedPaths = tree.getExpandedDescendants(rootPath);
    return new UIState(selectedPaths, expandedPaths);
}
 
Example 4
Source File: ProfilerTreeTable.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
static UIState getUIState(JTree tree) {
    TreePath[] selectedPaths = tree.getSelectionPaths();
    TreePath rootPath = new TreePath(tree.getModel().getRoot());
    Enumeration<TreePath> expandedPaths = tree.getExpandedDescendants(rootPath);
    return new UIState(selectedPaths, expandedPaths);
}