Java JTree Expand expandAll(JTree rightTree)

Here you can find the source of expandAll(JTree rightTree)

Description

expand All

License

Apache License

Declaration

public static void expandAll(JTree rightTree) 

Method Source Code


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

import java.util.Enumeration;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;

public class Main {
    public static void expandAll(JTree rightTree) {
        expandAll(rightTree, new TreePath(((DefaultMutableTreeNode) rightTree.getModel().getRoot()).getPath()));
    }//from w ww . j  ava2 s.c om

    public static void expandAll(JTree tree, TreePath parent) {
        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(tree, path);
            }
        }
        tree.expandPath(parent);
    }
}

Related

  1. expand(JTree tree, int depth)
  2. expand(JTree tree, int level)
  3. expand(JTree tree, int startingIndex, int rowCount)
  4. expandAll(final JTree tree, final TreePath parent, final boolean expand)
  5. expandAll(JTree jTree)
  6. expandAll(JTree t)
  7. expandAll(JTree tree)
  8. expandAll(JTree tree)
  9. expandAll(JTree tree)