Java JTree Path isDescendant(TreePath path1, final TreePath path2)

Here you can find the source of isDescendant(TreePath path1, final TreePath path2)

Description

Is path1 descendant of path2?

License

Open Source License

Declaration

public static boolean isDescendant(TreePath path1, final TreePath path2) 

Method Source Code

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

import javax.swing.tree.TreePath;

public class Main {
    /**// w w w.j av  a  2s. c o  m
     * Is path1 descendant of path2?
     */
    public static boolean isDescendant(TreePath path1, final TreePath path2) {
        int count1 = path1.getPathCount();
        final int count2 = path2.getPathCount();
        if (count1 <= count2) {
            return false;
        }
        while (count1 != count2) {
            path1 = path1.getParentPath();
            count1--;
        }
        return path1.equals(path2);
    }
}

Related

  1. getTreePath(TreePath path, JTree tree, boolean compareOnlyLabels)
  2. getTreePathString(TreePath path)
  3. getUpdatedTreePath(TreePath[] paths, JTree tree)
  4. getUserObject(TreePath path)
  5. getUserObject(TreePath path)
  6. isDescendant(TreePath path1, final TreePath path2)
  7. isFile(TreePath path)
  8. isSource(TreePath path)
  9. isTreePathContainedInExpansionState(TreePath treePath, ArrayList expansionStateStrings)