boolean (@Nullable JComponent component) { if (component == null) return false; Point location = MouseInfo.getPointerInfo().getLocation(); Point p = new Point(location); SwingUtilities.convertPointFromScreen(p, component); return component.getVisibleRect().contains(p); }