Here you can find the source of fullExpand(JTree tree, TreePath parentPath, int nExpansions)
private static int fullExpand(JTree tree, TreePath parentPath, int nExpansions)
//package com.java2s; import javax.swing.JTree; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; public class Main { private static int fullExpand(JTree tree, TreePath parentPath, int nExpansions) { TreeNode parent = (TreeNode) parentPath.getLastPathComponent(); int count = parent.getChildCount(); for (int i = 0; i < count && nExpansions > 0; ++i) { TreeNode child = parent.getChildAt(i); TreePath childPath = parentPath.pathByAddingChild(child); //ESCA-JAVA0119 nExpansions = fullExpand(tree, childPath, nExpansions); }// w ww.j a v a 2s.co m tree.expandPath(parentPath); return --nExpansions; } }