@Override
 public void doLayout() {
   for (Field field : usedFieldList) {
     Component component = field.getHandle().getDisplayer().getComponent();
     int r = field.getRow();
     int c = field.getColumn();
     component.setBounds(x(c), y(r), w(c), h(r));
   }
 }
  /**
   * Ensures that the field <code>row/column</code> shows <code>figure</code>.
   *
   * @param row the row of the field
   * @param column the column of the field
   * @param figure the figure to show, can be <code>null</code> if the field should be cleared.
   */
  public void put(int row, int column, ChessFigure figure) {
    Field field = fields[row][column];
    ChessFigure old = field.getFigure();

    if (old != null) {
      for (DockStationListener listener : listListeners()) listener.dockableRemoving(this, old);

      field.set(null);
      old.setDockParent(null);

      for (DockStationListener listener : listListeners()) listener.dockableRemoved(this, old);
    }

    if (figure != null) {
      Field oldField = getFieldOf(figure);
      if (oldField == null) {
        for (DockStationListener listener : listListeners()) listener.dockableAdding(this, figure);

        field.set(figure);
        figure.setDockParent(this);

        for (DockStationListener listener : listListeners()) listener.dockableAdded(this, figure);
      } else {
        field.transfer(oldField);
        if (!board.isEmpty(oldField.getRow(), oldField.getColumn())) {
          board.move(oldField.getRow(), oldField.getColumn(), row, column);
          Figure pawn = board.pawnReplacement();
          if (pawn != null) {
            pawn = pawnReplaceDialog.replace(pawn);
            board.put(pawn);
            figure.setFigure(pawn);
          }

          board.switchPlayer();
        }
      }
    }
  }
 public void replace(Dockable old, Dockable next) {
   Field field = getFieldOf(old);
   if (field == null) throw new IllegalArgumentException("Unknown dockable");
   put(field.getRow(), field.getColumn(), (ChessFigure) next);
 }
 public DockableProperty getDockableProperty(Dockable dockable, Dockable ignored) {
   Field field = getFieldOf(dockable);
   return new ChessBoardProperty(field.getRow(), field.getColumn());
 }
 public void drag(Dockable dockable) {
   Field field = getFieldOf(dockable);
   if (field != null) put(field.getRow(), field.getColumn(), null);
 }