Here you can find the source of RemoveAll(JTree tree)
public static void RemoveAll(JTree tree)
//package com.java2s; /**/*w w w . ja v a2 s .com*/ * CEDP: Computer Evaluator for Dependability and Performance * This file is distributed under the University of Illinois Open Source * License. See LICENSE.TXT for details. */ import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class Main { public static void RemoveAll(JTree tree) { // Tree root won't be removed. RemoveChildren((DefaultMutableTreeNode) tree.getModel().getRoot()); tree.updateUI(); } public static void RemoveChildren(DefaultMutableTreeNode node) { while (node.getChildCount() > 0) { RemoveChildren((DefaultMutableTreeNode) node.getFirstChild()); } //System.out.println("" + node); node.removeFromParent(); } }