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


public class h11a1 extends Applet
implements MouseListener, MouseMotionListener
{
 private int nx,ny=-10;
 private String s="";
 int x1=0;
 int y1=0;
 int x2=0;
 int y2=0;
 //g.setColor(new Color(0,255,255));
 //g.setFont(new Font("SansSerif",Font.PLAIN,24));

 public void init()
 {
 addMouseListener(this);
 addMouseMotionListener(this);
 }

 public void paint(Graphics g)
 {
 g.drawString(s,nx,ny); //+"["+nx+","+ny+"]",nx,ny);
 g.drawLine(x1,y1,x2,y2);
 g.drawString("x1="+x1,300,400);
 g.drawString("y1="+y1,350,400);
 g.drawString("x2="+x2,300,420);
 g.drawString("y2="+y2,350,420);
 }

 public void degerleriGir(String e,int x,int y)
 {
 s=e;
 nx=x;
 ny=y;
 repaint();
 }

 //fare dinleyicisinin dinledikleriyle ilgili cikti metodlari
 public void mouseClicked(MouseEvent e)
 { degerleriGir("Kliklendi",e.getX(),e.getY()); }
 public void mousePressed(MouseEvent e)
 {
   x1=e.getX();
   y1=e.getY();
   //degerleriGir("Basildi",e.getX(),e.getY());
  }
 public void mouseReleased(MouseEvent e)

 {
   repaint();
   //degerleriGir("Birakildi",e.getX(),e.getY());
    }
 public void mouseEntered(MouseEvent e)
 { showStatus("Fare applet alani icinde"); }
 public void mouseExited(MouseEvent e)
 { showStatus("Fare applet alani disinda"); }
 //MouseMotionListener (fare hareket dinleyicisi) metotlari
 public void mouseDragged(MouseEvent e)
 {
   x2=e.getX();
   y2=e.getY();
   repaint();
   //degerleriGir("basilip cekiliyor",e.getX(),e.getY());
  }
 public void mouseMoved(MouseEvent e)
 { degerleriGir("hareket halinde",e.getX(),e.getY()); }

}












