int (final Container container, final Insets insets) { int skipLayout = 0; GridLayoutManager parentGridLayout = null; GridConstraints parentGridConstraints = null; // "use parent layout" also needs to work in cases where a grid is the only control in a non-grid panel // which is contained in a grid Container parent = container.getParent(); if (parent != null) { if (parent.getLayout() instanceof GridLayoutManager) { parentGridLayout = (GridLayoutManager) parent.getLayout(); parentGridConstraints = parentGridLayout.getConstraintsForComponent(container); } else { Container parent2 = parent.getParent(); if (parent2 != null && parent2.getLayout() instanceof GridLayoutManager) { parentGridLayout = (GridLayoutManager) parent2.getLayout(); parentGridConstraints = parentGridLayout.getConstraintsForComponent(parent); } } } if (parentGridLayout != null && parentGridConstraints.isUseParentLayout()) { if (myRowStretches.length == parentGridConstraints.getRowSpan()) { int row = parentGridConstraints.getRow(); myYs[0] = insets.top + myMargin.top; myHeights[0] = parentGridLayout.myHeights[row] - myYs[0]; for (int i = 1; i < myRowStretches.length; i++) { myYs[i] = parentGridLayout.myYs[i + row] - parentGridLayout.myYs[row]; myHeights[i] = parentGridLayout.myHeights[i + row]; } myHeights[myRowStretches.length - 1] -= insets.bottom + myMargin.bottom; skipLayout |= SKIP_ROW; } if (myColumnStretches.length == parentGridConstraints.getColSpan()) { int col = parentGridConstraints.getColumn(); myXs[0] = insets.left + myMargin.left; myWidths[0] = parentGridLayout.myWidths[col] - myXs[0]; for (int i = 1; i < myColumnStretches.length; i++) { myXs[i] = parentGridLayout.myXs[i + col] - parentGridLayout.myXs[col]; myWidths[i] = parentGridLayout.myWidths[i + col]; } myWidths[myColumnStretches.length - 1] -= insets.right + myMargin.right; skipLayout |= SKIP_COL; } } return skipLayout; }