Java JTree is mouse event over tree

Description

Java JTree is mouse event over tree

import java.awt.event.MouseEvent;

import javax.swing.JTree;

public class Main {

   public static boolean isMouseOverTreePath(MouseEvent evt, JTree tree) {
      if (evt == null) {
          throw new NullPointerException("evt == null");
      }//from w w w.j  a va  2  s.  c o  m
      if (tree == null) {
          throw new NullPointerException("tree == null");
      }
      return tree.getRowForLocation(evt.getX(), evt.getY()) > 0;
  }   

}



PreviousNext

Related