Dimension (final @NotNull Container parent) { Dimension size = new Dimension(); Dimension leftSize = myLeft.getPreferredSize(); Dimension rightSize = myRight.getPreferredSize(); size.width = leftSize.width + rightSize.width; size.height = Math.max(leftSize.height, rightSize.height); JBInsets.addTo(size, parent.getInsets()); return size; }