// Demonstrating mouse events in an Applet 
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Lines1 extends Applet implements MouseListener  {    
   private int xStart = 0, yStart = 0 ;
   private int xEnd, yEnd;     
   private boolean first;
   private Font f;

   public void start()
   {
      first = true;
	  
   }
   public void stop()
   {

   }
   public void init()
   {
      // disable statements in paint initially
      first = true;


	  // Register the applet as a listener on itself
	  this.addMouseListener(this);
   }

   public void paint( Graphics g )
   {
      // these statements will not execute
      // on the first call to paint
      if ( first == false ) {
         g.drawLine( xStart, yStart, xEnd, yEnd );
		 xStart = xEnd;
		 yStart = yEnd;
      }
   }

   public void mouseClicked( MouseEvent e )
   {
	  first = false;
	  xEnd = e.getX();
	  yEnd = e.getY();
	  repaint();
   }
   public void mouseEntered(MouseEvent e) {}
   public void mouseExited(MouseEvent e) {}
   public void mousePressed(MouseEvent e) {}
   public void mouseReleased(MouseEvent e) {}


   public void update(Graphics g)
   {
	  // Do not clear the screen
	  paint(g);
   }

}
