FileDocCategorySizeDatePackage
PromotionDialog.javaAPI DocExample3054Sat Sep 12 03:01:00 BST 1998borland.samples.apps.chess.client.board

PromotionDialog

public class PromotionDialog extends Dialog implements MouseListener

Fields Summary
PromotionCanvas
pieceCanvas
ResourceBundle
res
Chessboard
dlgParent
Image
pieceImage
Constructors Summary
public PromotionDialog(Frame parent, Image pieceimage, Chessboard theParent)


       
    super(parent,"",false);
    setTitle(res.getString("Promote_your_pawn"));
    System.out.println("promotionDialog xtor");
    dlgParent = theParent;
    this.pieceImage = pieceimage;
    jbInit();
    setLayout(new FlowLayout());
  
Methods Summary
public java.awt.DimensiongetPreferredSize()

    Dimension d = super.getPreferredSize();
    if (d.width < 180)
      return new Dimension(180,d.height);
    else
      return d;

  
public voidjbInit()

    pieceCanvas.setImage(pieceImage);
    pieceCanvas.addMouseListener(this);
    add(pieceCanvas);
  
public voidmouseClicked(java.awt.event.MouseEvent parm1)

    //  java.awt.event.MouseListener method;
  
public voidmouseEntered(java.awt.event.MouseEvent parm1)

    //  java.awt.event.MouseListener method;
  
public voidmouseExited(java.awt.event.MouseEvent parm1)

    //  java.awt.event.MouseListener method;
  
public voidmousePressed(java.awt.event.MouseEvent parm1)

    // java.awt.event.MouseListener method;
    int  piecesub =  parm1.getX() * 4 / pieceCanvas.pieces.getWidth(this);
    if (piecesub > 3)
      piecesub = 3;
    dlgParent.promote(piecesub);
    dispose();
  
public voidmouseReleased(java.awt.event.MouseEvent parm1)

    //  java.awt.event.MouseListener method;