int secSize = getSizeForSecondaryAxis(preferredSize); if (secSize > preSecondary) preSecondary = secSize; prePrimary += getSizeForPrimaryAxis(insets, true) + getSizeForPrimaryAxis(insets, false); preSecondary += getSizeForSecondaryAxis(insets, true) + getSizeForSecondaryAxis(insets, false);
minPrimary += getSizeForPrimaryAxis(minimumSize); int secSize = getSizeForSecondaryAxis(minimumSize); if (secSize > minSecondary) minSecondary = secSize; minPrimary += getSizeForPrimaryAxis(insets, true) + getSizeForPrimaryAxis(insets, false); minSecondary += getSizeForSecondaryAxis(insets, true) + getSizeForSecondaryAxis(insets, false);
protected Dimension getPreferredSizeOf(Component comp, int atIndex) { // for JTextArea, the preferred size only returns the height of one line if the size is never set. if (comp instanceof JTextArea && getSizeForSecondaryAxis(comp.getSize()) == 0) { Insets insets = _target.getInsets(); ComponentOrientation o = _target.getComponentOrientation(); Dimension size = _target.getSize(); if (resolveAxis(_axis, o) == X_AXIS) { comp.setSize(new Dimension(comp.getPreferredSize().width, size.height - insets.top - insets.bottom)); } else { comp.setSize(new Dimension(size.width - insets.left - insets.right, comp.getPreferredSize().height)); } } Dimension preferredSize = comp.getPreferredSize(); Dimension minimumSize = comp.getMinimumSize(); if (preferredSize.height < minimumSize.height) { preferredSize.height = minimumSize.height; } if (preferredSize.width < minimumSize.width) { preferredSize.width = minimumSize.width; } Dimension maximumSize = comp.getMaximumSize(); if (preferredSize.height > maximumSize.height && maximumSize.height != 32767) { // 32767 is hard-coded inside Swing. If you set maximum size to null, the maximum size is 32767. preferredSize.height = maximumSize.height; } if (preferredSize.width > maximumSize.width && maximumSize.height != 32767) { preferredSize.width = maximumSize.width; } return preferredSize; }