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

public class Dots3 extends Applet implements MouseListener, MouseMotionListener {

    private final int APPLET_WIDTH = 200;
    private final int APPLET_HEIGHT = 100;
    private final int RADIUS = 6;

    private Point point0 = null;
    private Point point1 = null;

    public void init() {
	addMouseListener( this );
	addMouseMotionListener( this );
	setBackground( Color.black );
	setSize( APPLET_WIDTH,APPLET_HEIGHT );
    } // end of init()

    public void paint( Graphics g ) {
	g.setColor( Color.green );
	if ( point0 != null ) {
	    g.fillOval( point0.x-RADIUS,point0.y-RADIUS,RADIUS*2,RADIUS*2 );
	}
	if ( point1 != null ) {
	    g.fillOval( point1.x-RADIUS,point1.y-RADIUS,RADIUS*2,RADIUS*2 );
	}
	if (( point0 != null ) && ( point1 != null )) {
	    g.drawLine( point0.x,point0.y,point1.x,point1.y );
	}
    } // end of paint()

    public void mousePressed( MouseEvent evt ) {
	point0 = evt.getPoint();
    } // end of mousePressed()

    public void mouseDragged( MouseEvent evt ) {
	point1 = evt.getPoint();
	repaint();
    } // end of mouseDragged()

    public void mouseClicked( MouseEvent evt ) {
    } // end of mouseClicked()

    public void mouseReleased( MouseEvent evt ) {
    } // end of mouseReleased()

    public void mouseEntered( MouseEvent evt ) {
    } // end of mouseEntered()

    public void mouseExited( MouseEvent evt ) {
    } // end of mouseExited()

    public void mouseMoved( MouseEvent evt ) {
    } // end of mouseMoved()

} // end of Dots3 class
