Java JTree Path pathToDepth(TreePath path, int depth)

Here you can find the source of pathToDepth(TreePath path, int depth)

Description

path To Depth

License

Open Source License

Declaration

public static TreePath pathToDepth(TreePath path, int depth) 

Method Source Code

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

import javax.swing.tree.TreePath;

public class Main {
    public static TreePath pathToDepth(TreePath path, int depth) {
        TreePath returnPath = path;
        if (path.getPathCount() < depth)
            return new TreePath(new Object[0]);
        else {/*from   w w w.  j a v  a2  s  . c o m*/
            for (int i = path.getPathCount(); i > (depth + 1); i--) {
                returnPath = returnPath.getParentPath();
            }
        }
        return returnPath;
    }
}

Related

  1. loadExpansionState(JTree tree, Enumeration expansionState)
  2. makeLocalFilePath(TreePath treePath)
  3. makeTreePath(TreeNode treeNode)
  4. pathByAddingChildAsStr(TreePath currPath, String child)
  5. pathContains(TreePath[] paths, Class clazz)
  6. resourceFromTreePath(TreePath path)
  7. restoreSelectionPath(JTree parentTree)
  8. searchForNodeV2(TreeNode node, String query, JTree tree, TreePath actualPath, boolean isRoot)
  9. selectCategoryTreePath(JTree tree, TreePath treePath)