int (final int cellIndex) { int nonInheritingComponentsInCell = 0; int policyFromInheriting = -1; for(int i=getComponentCount() - 1; i >= 0; i--) { if (!componentBelongsCell(i, cellIndex)) { continue; } Component child = getComponent(i); GridConstraints c = getConstraints(i); Container container = findAlignedChild(child, c); if (container != null) { GridLayoutManager grid = (GridLayoutManager) container.getLayout(); grid.validateInfos(container); DimensionInfo info = getDimensionInfo(grid); final int policy = info.calcCellSizePolicy(cellIndex - getOriginalCell(c)); if (policyFromInheriting == -1) { policyFromInheriting = policy; } else { policyFromInheriting |= policy; } } else if (getOriginalCell(c) == cellIndex && getOriginalSpan(c) == 1 && !(child instanceof Spacer)) { nonInheritingComponentsInCell++; } } if (nonInheritingComponentsInCell > 0) { return -1; } return policyFromInheriting; }