MyButtonpublic 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 boolean | gotFocus(java.awt.Event evt, java.lang.Object w)
TextField t =
(TextField)parent.h.get("gotFocus");
t.setText(evt.toString());
return true;
| public boolean | keyDown(java.awt.Event evt, int key)
TextField t =
(TextField)parent.h.get("keyDown");
t.setText(evt.toString());
return true;
| public boolean | keyUp(java.awt.Event evt, int key)
TextField t =
(TextField)parent.h.get("keyUp");
t.setText(evt.toString());
return true;
| public boolean | lostFocus(java.awt.Event evt, java.lang.Object w)
TextField t =
(TextField)parent.h.get("lostFocus");
t.setText(evt.toString());
return true;
| public boolean | mouseDown(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseDown");
t.setText(evt.toString());
return true;
| public boolean | mouseDrag(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseDrag");
t.setText(evt.toString());
return true;
| public boolean | mouseEnter(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseEnter");
t.setText(evt.toString());
return true;
| public boolean | mouseExit(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseExit");
t.setText(evt.toString());
return true;
| public boolean | mouseMove(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseMove");
t.setText(evt.toString());
return true;
| public boolean | mouseUp(java.awt.Event evt, int x, int y)
TextField t =
(TextField)parent.h.get("mouseUp");
t.setText(evt.toString());
return true;
| public void | paint(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);
|
|