FileDocCategorySizeDatePackage
AutoEvent.javaAPI DocExample5796Mon Apr 06 18:10:22 BST 1998None

MyButton

public class MyButton extends Canvas

Fields Summary
AutoEvent
parent
Color
color
String
label
Constructors Summary
MyButton(AutoEvent parent, Color color, String label)

    this.label = label;
    this.parent = parent;
    this.color = color;
  
Methods Summary
public booleangotFocus(java.awt.Event evt, java.lang.Object w)

    TextField t = 
      (TextField)parent.h.get("gotFocus");
    t.setText(evt.toString());
    return true;
  
public booleankeyDown(java.awt.Event evt, int key)

    TextField t = 
      (TextField)parent.h.get("keyDown");
    t.setText(evt.toString());
    return true;
  
public booleankeyUp(java.awt.Event evt, int key)

    TextField t = 
      (TextField)parent.h.get("keyUp");
    t.setText(evt.toString());
    return true;
  
public booleanlostFocus(java.awt.Event evt, java.lang.Object w)

    TextField t = 
      (TextField)parent.h.get("lostFocus");
    t.setText(evt.toString());
    return true;
  
public booleanmouseDown(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseDown");
    t.setText(evt.toString());
    return true;
  
public booleanmouseDrag(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseDrag");
    t.setText(evt.toString());
    return true;
  
public booleanmouseEnter(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseEnter");
    t.setText(evt.toString());
    return true;
  
public booleanmouseExit(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseExit");
    t.setText(evt.toString());
    return true;
  
public booleanmouseMove(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseMove");
    t.setText(evt.toString());
    return true;
  
public booleanmouseUp(java.awt.Event evt, int x, int y)

    TextField t = 
      (TextField)parent.h.get("mouseUp");
    t.setText(evt.toString());
    return true;
  
public voidpaint(java.awt.Graphics g)

    g.setColor(color);
    int rnd = 30;
    g.fillRoundRect(0, 0, size().width, 
                    size().height, rnd, rnd);
    g.setColor(Color.black);
    g.drawRoundRect(0, 0, size().width, 
                    size().height, rnd, rnd);
    FontMetrics fm = g.getFontMetrics();
    int width = fm.stringWidth(label);
    int height = fm.getHeight();
    int ascent = fm.getAscent();
    int leading = fm.getLeading();
    int horizMargin = (size().width - width)/2;
    int verMargin = (size().height - height)/2;
    g.setColor(Color.white);
    g.drawString(label, horizMargin, 
                 verMargin + ascent + leading);