Ejemplo n.º 1
0
    /**
     * Sets the {@link Dockable} which is shown on this field.
     *
     * @param figure the new dockable, might be <code>null</code>
     */
    public void set(ChessFigure figure) {
      ChessFigure old = this.figure;

      if (this.figure != null) {
        getContentPane().remove(handle.getDisplayer().getComponent());

        handle.destroy();
        this.figure = null;
        this.handle = null;
      }

      this.figure = figure;

      if (this.figure != null) {
        DockTitleVersion version = null;
        if (controller != null)
          version = controller.getDockTitleManager().getVersion("chess-board");
        handle = new StationChildHandle(ChessBoard.this, displayerCollection, figure, version);
        handle.updateDisplayer();
        getContentPane().add(handle.getDisplayer().getComponent());
      }

      if (old == null && figure != null) usedFieldList.add(this);
      else if (old != null && figure == null) usedFieldList.remove(this);

      getContentPane().revalidate();
    }
Ejemplo n.º 2
0
 /**
  * Ensures that the correct {@link DockTitle} for the current {@link #set(ChessFigure) figure}
  * is shown.
  */
 public void updateTitle() {
   if (handle != null) {
     if (controller == null) {
       handle.setTitleRequest(null);
     } else {
       DockTitleVersion version = controller.getDockTitleManager().getVersion("chess-board");
       handle.setTitleRequest(version);
     }
   }
 }