List of usage examples for javax.swing.tree TreePath isDescendant
public boolean isDescendant(TreePath aTreePath)
aTreePath
is a descendant of this TreePath . From source file:mobac.gui.components.JMapSourceTree.java
/** * Check if the mouse cursor was over a clickable node * /* w w w. j a v a2 s. c o m*/ * @param eventPoint * - a mouse position coordinates * @return true if a node was clickable, false otherwise */ public boolean isLocationClickable(Point eventPoint) { int x = (int) eventPoint.getX(); int y = (int) eventPoint.getY(); TreePath treePathForXY = getPathForLocation(x, y); // If a node is an ancestor of a currently selected node - it can't be closed, so it is unclickable. if (treePathForXY != null && treePathForXY.isDescendant(findTreePathOfMapSource(selectedMapSource))) { return false; } boolean isInside = false; if (treePathForXY != null) { Rectangle pathBounds = this.getPathBounds(treePathForXY); isInside = pathBounds.contains(eventPoint); } return isInside; }