コード例 #1
0
 public PieceView(Piece piece) {
   super();
   piece.addPieceObserver(this);
   setHorizontalAlignment(CENTER);
   setFont(new Font("Sans Serif", Font.BOLD, 10));
   String playerName = piece.getOwner().getName();
   setText(playerName.substring(playerName.length() - 1, playerName.length()));
 }
コード例 #2
0
  @Override
  public void update(Piece piece) {
    // TODO Auto-generated method stub
    SquareView parent = getSquareView();

    if (parent != null) {
      parent.removePieceView(this);
    }

    Square square = piece.getCurrentLocation();
    SquareView squareView = (SquareView) square.getSquareObservers().get(0);
    squareView.addPieceView(this);
  }