import java.applet.*;
import java.awt.*;
import java.awt.event.*;

class Fenetre extends Frame {
	TextArea t;
	
	Fenetre(String titre) { 
		super(titre);
		t = new TextArea("(x, y)", 5, 20);
		add("Center", t);
		pack();
		show();
	}
	
	public void afficher(String s) {
		t.append(s);
	}
}

public class Interaction extends Applet {

	int x0 = 0, y0 = 0;
	Fenetre f1;
	
	
	class MSouris extends MouseMotionAdapter {
		public void mouseDragged(MouseEvent e) {
			Graphics g = getGraphics();
			g.drawLine(x0, y0, e.getX(), e.getY());
			f1.afficher("\n("+x0+","+y0+")->("+e.getX()+","+e.getY()+")");
			x0 = e.getX(); y0 = e.getY();
		}
	}
	
	class CSouris extends MouseAdapter {
		public void mousePressed(MouseEvent e) {
			x0 = e.getX(); y0 = e.getY();
		}
	}
	
	public void init() {
		f1 = new Fenetre("f1");
		addMouseListener(new CSouris());
		addMouseMotionListener(new MSouris());
	}
	public void stop() {
		f1.dispose();
	}
}