Dimension () { Dimension size = super.getPreferredSize(); if (myHorizontalSizeReferent != null && myHorizontalSizeReferent.isShowing()) { size.width = Math.max(size.width, myHorizontalSizeReferent.getPreferredSize().width); } if (myVerticalSizeReferent != null && myVerticalSizeReferent.isShowing()) { size.height = Math.max(size.height, myVerticalSizeReferent.getPreferredSize().height); } return size; }