Example usage for javax.swing.tree DefaultTreeModel getChildCount

List of usage examples for javax.swing.tree DefaultTreeModel getChildCount

Introduction

In this page you can find the example usage for javax.swing.tree DefaultTreeModel getChildCount.

Prototype

public int getChildCount(Object parent) 

Source Link

Document

Returns the number of children of parent.

Usage

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();
    }
}