Java JTree Node getLevel(TreeNode treeNode)

Here you can find the source of getLevel(TreeNode treeNode)

Description

get Level

License

Open Source License

Declaration

public static final int getLevel(TreeNode treeNode) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.tree.TreeNode;

public class Main {
    public static final int getLevel(TreeNode treeNode) {
        int count = -1;
        TreeNode current = treeNode;
        do {//  www.j  a  va  2 s .c o m
            current = current.getParent();
            count++;
        } while (current != null);

        return count;
    }
}

Related

  1. findTreeNodesWithLowestLevel(List multipleTreeNodes)
  2. findTreeNodeWithXmlPath(DefaultMutableTreeNode treeNode, String nodeXmlPath)
  3. getAllChildCount(TreeNode node)
  4. getAllTreeNodes(TreeModel model, int startLevel, Class clazz, DefaultMutableTreeNode root)
  5. getAllUserObject(TreeNode node, Set userObjectSet)
  6. getMutableTreeNodes(TreeNode[] path)
  7. getNodeAt(final JTree tree, final int x, final int y)
  8. getNodeForEvent(JTree targetTree, DropTargetDragEvent dtde)
  9. getPathStringForNode(DefaultMutableTreeNode node)