import java.applet.Applet;
import java.util.Random;
import java.awt.*;

public class MousePoint extends Applet {
  int x0, y0;
  Color cl;
  String s = null;
  Graphics g;

  public void init() {
    x0 = 10;
    y0 = 20;
    cl = Color.red;
    s = getParameter("TEXT");
    if (s == null)
      s = "TEXT is nothing.";
    setBackground(Color.white);
    resize(300,100);
    setFont(new Font("TimesRoman", Font.ITALIC, 12));
    g = getGraphics();
    add(new ClearButton(g));
  }
  public void paint(Graphics g) {
    g.setColor(cl);
    g.drawString(s, x0, y0);
  }
  public void update(Graphics g) {
    paint(g);
  }
  public void randompaint(int x, int y) {
    Graphics g = this.getGraphics();
    for (int i=0;i<10;i++) {
      Random ran = new Random();
      x0 = ran.nextInt() % 25;
      y0 = ran.nextInt() % 25;
      int z = (ran.nextInt() % 127) + 128;
      cl = new Color((x0+25)*5, (y0+25)*5, z);
      x0 = x0 + x - s.length();
      y0 = y0 + y;
      update(g);
    }
  }    
  public boolean mouseDown(Event e, int x, int y){
    randompaint(x,y);
    return true;
  }
}
