Java JTree Node getAllChildCount(TreeNode node)

Here you can find the source of getAllChildCount(TreeNode node)

Description

get All Child Count

License

Apache License

Declaration

public static int getAllChildCount(TreeNode node) 

Method Source Code

//package com.java2s;
/*//from   w  w w .  j ava  2s.co m
 * K-scope
 * Copyright 2012-2013 RIKEN, Japan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Version to work with SSHconnect.
 */

import javax.swing.tree.TreeNode;

public class Main {

    public static int getAllChildCount(TreeNode node) {
        if (node == null)
            return 0;
        int count = 0;
        int childCount = node.getChildCount();
        for (int i = 0; i < childCount; i++) {
            count++;
            TreeNode child = node.getChildAt(i);
            count += getAllChildCount(child);
        }
        return count;
    }
}

Related

  1. expandTreeRecurser(JTree tree, DefaultMutableTreeNode node)
  2. export(File file, DefaultMutableTreeNode node)
  3. findFirstTreeNodeMatchUserObject(DefaultMutableTreeNode treeNode, Object userObject)
  4. findTreeNodesWithLowestLevel(List multipleTreeNodes)
  5. findTreeNodeWithXmlPath(DefaultMutableTreeNode treeNode, String nodeXmlPath)
  6. getAllTreeNodes(TreeModel model, int startLevel, Class clazz, DefaultMutableTreeNode root)
  7. getAllUserObject(TreeNode node, Set userObjectSet)
  8. getLevel(TreeNode treeNode)
  9. getMutableTreeNodes(TreeNode[] path)