void (final @NotNull Container parent) { Insets insets = parent.getInsets(); Dimension size = parent.getSize(); Dimension prefSize = parent.getPreferredSize(); if (prefSize.width <= size.width) { myLeft.setBounds(insets.left, insets.top, myLeft.getPreferredSize().width, parent.getHeight() - insets.bottom); Dimension rightSize = myRight.getPreferredSize(); myRight.setBounds(parent.getWidth() - rightSize.width - insets.left, insets.top, rightSize.width, parent.getHeight() - insets.bottom); } else { Dimension leftMinSize = myLeft.getMinimumSize(); Dimension rightMinSize = myRight.getMinimumSize(); // see IDEA-140557, always shrink left component last int delta = 0; //int delta = (prefSize.width - size.width) / 2; myLeft.setBounds(insets.left, insets.top, myLeft.getPreferredSize().width - delta, parent.getHeight() - insets.bottom); int rightX = (int)myLeft.getBounds().getMaxX(); int rightWidth = size.width - rightX - insets.right; if (rightWidth < rightMinSize.width) { Dimension leftSize = myLeft.getSize(); int diffToRightMin = rightMinSize.width - rightWidth; if (leftSize.width - diffToRightMin >= leftMinSize.width) { leftSize.width -= diffToRightMin; myLeft.setSize(leftSize); } } myRight.setBounds((int)myLeft.getBounds().getMaxX(), insets.top, parent.getWidth() - (int)myLeft.getBounds().getMaxX() - insets.right, parent.getHeight() - insets.bottom); } toMakeVerticallyInCenter(myLeft, parent); toMakeVerticallyInCenter(myRight, parent); }