Java AWT MouseEvent is mouse event over JTree

Description

Java AWT MouseEvent is mouse event over JTree

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 ww . jav a  2 s.c  om
      if (tree == null) {
          throw new NullPointerException("tree == null");
      }
      return tree.getRowForLocation(evt.getX(), evt.getY()) > 0;
  }   

}



PreviousNext

Related