Here you can find the source of expandAllNode(JTree tree, TreePath parent)
private static void expandAllNode(JTree tree, TreePath parent)
//package com.java2s; import java.util.Enumeration; import javax.swing.JTree; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; public class Main { private static void expandAllNode(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); expandAllNode(tree, path); }//from w w w . j a v a 2 s . c o m } // end of if tree.expandPath(parent); } }