Dimension () { Dimension size = super.getPreferredSize(); if (myAnchor != null && myAnchor != this) { Dimension anchorSize = myAnchor.getPreferredSize(); size.width = Math.max(size.width, anchorSize.width); size.height = Math.max(size.height, anchorSize.height); } return size; }