void (MouseEvent e) { Rectangle bounds = getBoundsOnScreen(myContent); if (bounds != null) { bounds.x -= 2; bounds.y -= 2; bounds.width += 4; bounds.height += 4; } if (bounds == null || !bounds.contains(e.getLocationOnScreen())) { cancel(); } }