for (int i = 0; i < rowCount; i++) {
TablePane.Row row = rows.get(i);
for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
Component component = row.get(j);
if (component != null
&& component.isDisplayable()) {
int rowSpan = TablePane.getRowSpan(component);
if (rowSpan > 1) {
// We might need to adjust row heights to accomodate
// this spanning cell. First, we find out if any of the
// spanned cells are default height and how much space
// we've allocated thus far for those cells
int spannedDefaultHeightCellCount = 0;
int spannedRelativeWeight = 0;
int spannedHeight = 0;
for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
if (defaultHeightRows[i + k]) {
spannedDefaultHeightCellCount++;
}
if (rowHeights[i + k] < 0) {
spannedRelativeWeight += -rowHeights[i + k];
} else {
spannedHeight += rowHeights[i + k];
}
}
// If we span any relative-height rows, we assume
// that we'll achieve the desired spanning height when
// we divvy up the remaining space, so there's no need
// to make an adjustment here. This assumption is safe
// because our preferred height policy is to *either*
// divide the adjustment among the relative-height
// rows *or* among the default-height rows if we
// don't span any relative-height rows
if (spannedRelativeWeight == 0
&& spannedDefaultHeightCellCount > 0) {
TablePane.Column column = columns.get(j);
int columnWidth = -1;
if (columnWidths != null) {
columnWidth = columnWidths[j];
} else if (!column.isRelative()) {
columnWidth = column.getWidth();
}
int componentPreferredHeight =
component.getPreferredHeight(columnWidth);
if (componentPreferredHeight > spannedHeight) {
// The component's preferred height is larger
// than the height we've allocated thus far, so
// an adjustment is necessary