code: static public boolean isMouseWithinComponent(Component component) {
          Point mousePos = MouseInfo.getPointerInfo().getLocation();
          Rectangle bounds = component.getBounds();
          bounds.setLocation(component.getLocationOnScreen());
          return bounds.contains(mousePos);
      }
docs: isMouseWithinComponent, This returns true if the mouse is inside of the specified component,
  otherwise returns false.