void (final Component comp, final Object constraints) { final GridConstraints c = (GridConstraints)constraints; final int row = c.getRow(); final int rowSpan = c.getRowSpan(); final int rowCount = getRowCount(); if (row < 0 || row >= rowCount) { throw new IllegalArgumentException("wrong row: " + row); } if (row + rowSpan - 1 >= rowCount) { throw new IllegalArgumentException("wrong row span: " + rowSpan + "; row=" + row + " rowCount=" + rowCount); } final int column = c.getColumn(); final int colSpan = c.getColSpan(); final int columnCount = getColumnCount(); if (column < 0 || column >= columnCount) { throw new IllegalArgumentException("wrong column: " + column); } if (column + colSpan - 1 >= columnCount) { throw new IllegalArgumentException( "wrong col span: " + colSpan + "; column=" + column + " columnCount=" + columnCount); } super.addLayoutComponent(comp, constraints); }