import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Followme   extends Applet implements MouseListener, MouseMotionListener {

       private int last_x = 20, last_y = 20;
       private int x, y;

       public void init() {
              this.setBackground(Color.red); //Hintergrund wird gemalt
              this.addMouseListener(this);
              this.addMouseMotionListener(this);
       }

       public void paint(Graphics g) { // Startkreis wird gemalt
              g.setColor(Color.yellow);
              g.fillOval(last_x, last_y, 40, 40);
       }


    public void mouseClicked (MouseEvent e) { // Kreis hüpf!
           Graphics g = this.getGraphics();
           g.setColor(Color.red);
           g.fillOval(last_x, last_y, 40, 40);
           g.setColor(Color.yellow);
           last_x = e.getX() - 20;
           last_y = e.getY() - 20;
           g.fillOval(last_x, last_y, 40, 40);
    }

    public void mouseDragged (MouseEvent e) {  // kennt einer noch Zini?
           Graphics g = this.getGraphics();
           g.setColor(Color.red);
           g.fillOval(last_x, last_y, 40, 40);
           g.setColor(Color.yellow);
           last_x = e.getX() - 20;
           last_y = e.getY() - 20;
           g.fillOval(last_x, last_y, 40, 40);

    }

    // die nicht verwendeten Methoden des MouseListeners
    public void mouseReleased (MouseEvent e) { }
    public void mouseEntered (MouseEvent e) { }
    public void mouseExited (MouseEvent e) { }
    public void mousePressed (MouseEvent e) { }



    // Die andere, nicht verwendete Methode des MouseMotionListener-Interfaces
    public void mouseMoved (MouseEvent e) { }
}

