Rectangle () { Rectangle ownerRec = myOwner == null ? new Rectangle(0, 0, 0, 0) : myOwner.getBounds(); Dimension size = getPreferredSize(); int x = (ownerRec.width - size.width) / 2; int y = (ownerRec.height - size.height) / (myShowAboveCenter ? 3 : 2); return new Rectangle(x, y, size.width, size.height); }