RelativeRectangle (JComponent target, Rectangle screenRectangle) { Point relativePoint = screenRectangle.getLocation(); SwingUtilities.convertPointFromScreen(relativePoint, target); return new RelativeRectangle(new RelativePoint(target, relativePoint), screenRectangle.getSize()); }