Dimension () { if (isMinimumSizeSet()) return super.getMinimumSize(); // do not violate Swing's contract final int dividerWidth = getDividerWidth(); if (myFirstComponent != null && myFirstComponent.isVisible() && mySecondComponent != null && mySecondComponent.isVisible()) { final Dimension firstMinSize = myFirstComponent.getMinimumSize(); final Dimension secondMinSize = mySecondComponent.getMinimumSize(); return isVertical() ? new Dimension(Math.max(firstMinSize.width, secondMinSize.width), firstMinSize.height + dividerWidth + secondMinSize.height) : new Dimension(firstMinSize.width + dividerWidth + secondMinSize.width, Math.max(firstMinSize.height, secondMinSize.height)); } if (myFirstComponent != null && myFirstComponent.isVisible()) { // only first component is visible return myFirstComponent.getMinimumSize(); } if (mySecondComponent != null && mySecondComponent.isVisible()) { // only second component is visible return mySecondComponent.getMinimumSize(); } return super.getMinimumSize(); }