/*ch0704.java*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ch0704 extends JApplet implements MouseListener,MouseMotionListener
{ int x1,y1,x2,y2;
  public void init()
  { addMouseListener(this);
    addMouseMotionListener(this);
  }
  public void paint(Graphics g)
  { g.drawLine(x1,y1,x2,y2);
  }
  public void mousePressed(MouseEvent e)
  { x1=e.getX();       //获得鼠标按下时的横坐标
    y1=e.getY();       //获得鼠标按下时的纵坐标
  }
  public void mouseClicked(MouseEvent e) { }
  public void mouseEntered(MouseEvent e) { }
  public void mouseExited(MouseEvent e){ }
  public void mouseReleased(MouseEvent e){ }
  public void mouseDragged(MouseEvent e)
  { x2=e.getX( );            //获得放开鼠标时,鼠标此时的横坐标
    y2=e.getY( );            //获得放开鼠标时,鼠标此时的纵坐标
    repaint( );
  }
  public void mouseMoved(MouseEvent e){ }
}

