List of usage examples for javax.swing.tree DefaultTreeModel getChildCount
public int getChildCount(Object parent)
From source file:ser321.media.MediaJavaClient.java
private void clearTree(DefaultMutableTreeNode root, DefaultTreeModel model) { try {// ww w . j a v a 2s .c o m DefaultMutableTreeNode next = null; int subs = model.getChildCount(root); for (int k = subs - 1; k >= 0; k--) { next = (DefaultMutableTreeNode) model.getChild(root, k); debug("removing node labelled:" + (String) next.getUserObject()); model.removeNodeFromParent(next); } } catch (Exception ex) { System.out.println("Exception while trying to clear tree:"); ex.printStackTrace(); } }