public void layoutContainer(Container container) { this.validateInfos(container); LayoutState layoutState = this.myLayoutState; DimensionInfo horizontalInfo = this.myHorizontalInfo; DimensionInfo verticalInfo = this.myVerticalInfo; Insets insets = getInsets(container); int skipLayout = this.checkSetSizesFromParent(container, insets); Dimension gap = this.getTotalGap(container, horizontalInfo, verticalInfo); Dimension size = container.getSize(); size.width -= gap.width; size.height -= gap.height; Dimension prefSize = this.preferredLayoutSize(container); prefSize.width -= gap.width; prefSize.height -= gap.height; Dimension minSize = this.minimumLayoutSize(container); minSize.width -= gap.width; minSize.height -= gap.height; int[] i; int c; int component; if ((skipLayout & 1) == 0) { if (this.mySameSizeVertically) { i = getSameSizes(verticalInfo, Math.max(size.height, minSize.height)); } else if (size.height < prefSize.height) { i = this.getMinSizes(verticalInfo); this.new_doIt(i, 0, verticalInfo.getCellCount(), size.height, verticalInfo, true); } else { i = this.getPrefSizes(verticalInfo); this.new_doIt(i, 0, verticalInfo.getCellCount(), size.height, verticalInfo, false); } c = insets.top + this.myMargin.top; for (component = 0; component < i.length; ++component) { this.myYs[component] = c; this.myHeights[component] = i[component]; c += i[component]; if (shouldAddGapAfterCell(verticalInfo, component)) { c += verticalInfo.getGap(); } } } if ((skipLayout & 2) == 0) { if (this.mySameSizeHorizontally) { i = getSameSizes(horizontalInfo, Math.max(size.width, minSize.width)); } else if (size.width < prefSize.width) { i = this.getMinSizes(horizontalInfo); this.new_doIt(i, 0, horizontalInfo.getCellCount(), size.width, horizontalInfo, true); } else { i = this.getPrefSizes(horizontalInfo); this.new_doIt(i, 0, horizontalInfo.getCellCount(), size.width, horizontalInfo, false); } c = insets.left + this.myMargin.left; for (component = 0; component < i.length; ++component) { this.myXs[component] = c; this.myWidths[component] = i[component]; c += i[component]; if (shouldAddGapAfterCell(horizontalInfo, component)) { c += horizontalInfo.getGap(); } } } for (int index = 0; index < layoutState.getComponentCount(); ++index) { GridConstraints constraints = layoutState.getConstraints(index); Component cmpnt = layoutState.getComponent(index); int column = horizontalInfo.getCell(index); int colSpan = horizontalInfo.getSpan(index); int row = verticalInfo.getCell(index); int rowSpan = verticalInfo.getSpan(index); int cellWidth = this.myXs[column + colSpan - 1] + this.myWidths[column + colSpan - 1] - this.myXs[column]; int cellHeight = this.myYs[row + rowSpan - 1] + this.myHeights[row + rowSpan - 1] - this.myYs[row]; Dimension componentSize = new Dimension(cellWidth, cellHeight); if ((constraints.getFill() & 1) == 0) { componentSize.width = Math.min(componentSize.width, horizontalInfo.getPreferredWidth(index)); } if ((constraints.getFill() & 2) == 0) { componentSize.height = Math.min(componentSize.height, verticalInfo.getPreferredWidth(index)); } Util.adjustSize(cmpnt, constraints, componentSize); int dx = 0; int dy = 0; if ((constraints.getAnchor() & 4) != 0) { dx = cellWidth - componentSize.width; } else if ((constraints.getAnchor() & 8) == 0) { dx = (cellWidth - componentSize.width) / 2; } if ((constraints.getAnchor() & 2) != 0) { dy = cellHeight - componentSize.height; } else if ((constraints.getAnchor() & 1) == 0) { dy = (cellHeight - componentSize.height) / 2; } int indent = 10 * constraints.getIndent(); componentSize.width -= indent; dx += indent; cmpnt.setBounds( this.myXs[column] + dx, this.myYs[row] + dy, componentSize.width, componentSize.height); } }