Here you can find the source of getTreeModelSize(TreeModel in)
Parameter | Description |
---|---|
in | - the tree model |
public static int getTreeModelSize(TreeModel in)
//package com.java2s; //License from project: Apache License import javax.swing.tree.*; public class Main { /**/*w w w . ja v a2 s.c o m*/ return the size of a tree model @param in - the tree model @return - the size >= 0 */ public static int getTreeModelSize(TreeModel in) { Object root = in.getRoot(); if (root == null) return (0); return (getTreeModelSize(in, root)); } /** return the size of a tree starting at a specific root @param in - the tree model @parem root - starting node - non-null @return - the size >= 1 */ protected static int getTreeModelSize(TreeModel in, Object root) { int ret = 1; // add one for root for (int i = 0; i < in.getChildCount(root); i++) ret += getTreeModelSize(in, in.getChild(root, i)); return (ret); } }