I made an applet to make a cross across the screen. The only problem is that it leaves a trail when I drag it and it doesn't erase.

-------------------------------------------------
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.SwingUtilities;

public class Crosshair extends JApplet{

private int APPLET_WIDTH = 550, APPLET_HEIGHT = 415;
private int sX, sY; //0, 0 by default
private int eX, eY; //1, 1 by default
Point start;
Point end;

Graphics g;
JApplet a;


public void init(){

setSize( APPLET_WIDTH, APPLET_HEIGHT );

setBackground(Color.white);

mouseListener mmm = new mouseListener();
addMouseListener(mmm);
addMouseMotionListener(mmm);

g = getGraphics();

}// end init


public void paint(Graphics g){

int width = getSize().width;
int height = getSize().height;

g.setColor (Color.blue);
g.drawLine (sX, sY, eX, eY);

//Crosshair Starts
g.setColor(Color.black);

g.drawLine(eX, eY, width, eY);
g.drawLine(eX, eY, -width, eY);
g.drawLine(eX, eY, eX, height);
g.drawLine(eX, eY, eX, -height);


}//end paint

class mouseListener extends MouseInputAdapter{

public void mousePressed(MouseEvent e){

sX = e.getX();
sY = e.getY();

repaint();

}// end mousePressed

public void mouseDragged(MouseEvent e){

eX = e.getX();
eY = e.getY();

repaint();

}//end mouseDragged

public void mouseReleased(MouseEvent e){

eX = e.getX();
eY = e.getY();

repaint();


}//end mouseReleased

public void mouseClicked(MouseEvent e){

sX = e.getX();
sY = e.getY();

}// end mouseClicked

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseMoved(MouseEvent e){}


}//end mouseListner


}//end Crosshair