Dimension (Container parent) { Insets insets = parent.getInsets(); Dimension adSize = myAdvertiser.getAdComponent().getMinimumSize(); Dimension hintButtonSize = myHintButton.getMinimumSize(); Dimension menuButtonSize = myMenuButton.getMinimumSize(); return new Dimension(adSize.width + hintButtonSize.width + menuButtonSize.width + insets.left + insets.right, Math.max(adSize.height, menuButtonSize.height) + insets.top + insets.bottom); }