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