Hi all
I have an
Applet that implements MouseListener and MouseMotionListener events.
In mousePressed() method i'm writing code to draw a point on the location where the mouse was pressed.
In mouseMoved() method (the problem) I'm trying to write code so that the coordinates of the mouse pointer are displayed...I managed to do the following :
int xMove,yMove;
public void mouseMoved(MouseEvent e) {
Graphics g=getGraphics();
//erase old mouse location coordinates
g.setColor(this.getBackground());
g.drawString("+",xMove,yMove);
g.drawString(""+Integer.toString(xMove)+","+Integer.toString(yMove)+"",xMove+10,yMove-10);
xMove = e.getX();
yMove = e.getY();
//paint new mouse location coordinates
g.setColor(Color.black);
g.drawString("+",xMove,yMove);
g.drawString(""+Integer.toString(xMove)+","+Integer.toString(yMove)+"",xMove+10,yMove-10);
}
the problem of this method is that when i move pointer over an already painted point ; this point is erased from the screen !
I want the mouse pointer to be showed over all painted shapes on my applet.
can you give me a hint on how to do that ?
many thanks.