@Override public Dimension getPreferredSize() { final int dividerWidth = getDividerWidth(); if (myFirstComponent != null && myFirstComponent.isVisible() && mySecondComponent != null && mySecondComponent.isVisible()) { final Dimension firstPrefSize = myFirstComponent.getPreferredSize(); final Dimension secondPrefSize = mySecondComponent.getPreferredSize(); return isVertical() ? new Dimension(Math.max(firstPrefSize.width, secondPrefSize.width), firstPrefSize.height + dividerWidth + secondPrefSize.height) : new Dimension(firstPrefSize.width + dividerWidth + secondPrefSize.width, Math.max(firstPrefSize.height, secondPrefSize.height)); } if (myFirstComponent != null && myFirstComponent.isVisible()) { // only first component is visible return myFirstComponent.getPreferredSize(); } if (mySecondComponent != null && mySecondComponent.isVisible()) { // only second component is visible return mySecondComponent.getPreferredSize(); } return super.getPreferredSize(); } public void skipNextLayouting() {
public float getMinProportion(boolean first) { JComponent component = first? myFirstComponent : mySecondComponent; if (isHonorMinimumSize()) { if (component != null && myFirstComponent != null && myFirstComponent.isVisible() && mySecondComponent != null && mySecondComponent.isVisible()) { if (isVertical()) { return (float)component.getMinimumSize().height / (float)(getHeight() - getDividerWidth()); } else { return (float)component.getMinimumSize().width / (float)(getWidth() - getDividerWidth()); } } } return 0.0f; }
@Override public Dimension getMinimumSize() { 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(); }
Rectangle secondRect = new Rectangle(); int d = getDividerWidth(); double size1;