FileDocCategorySizeDatePackage
ToeTest.javaAPI DocExample5109Mon Apr 06 18:10:22 BST 1998None

ToeButton

public class ToeButton extends Canvas

Fields Summary
int
state
ToeDialog
parent
Constructors Summary
ToeButton(ToeDialog parent)

    
    this.parent = parent;
  
Methods Summary
public booleanmouseDown(java.awt.Event evt, int x, int y)

    if(state == ToeDialog.BLANK) {
      state = parent.turn;
      parent.turn= (parent.turn == ToeDialog.XX ?
        ToeDialog.OO : ToeDialog.XX);
    } 
    else
      state = (state == ToeDialog.XX ? 
        ToeDialog.OO : ToeDialog.XX);
    repaint();
    return true;
  
public voidpaint(java.awt.Graphics g)

    int x1 = 0;
    int y1 = 0;
    int x2 = size().width - 1;
    int y2 = size().height - 1;
    g.drawRect(x1, y1, x2, y2);
    x1 = x2/4;
    y1 = y2/4;
    int wide = x2/2;
    int high = y2/2;
    if(state == ToeDialog.XX) {
      g.drawLine(x1, y1, x1 + wide, y1 + high);
      g.drawLine(x1, y1 + high, x1 + wide, y1);
    }
    if(state == ToeDialog.OO) {
      g.drawOval(x1, y1, x1+wide/2, y1+high/2);
    }