I'm working on a graphics program that displays a plot and, when the user moves the cursor over the plot, moves to the (x,y) location of the data point. To do this, I'm using a Robot. However, when I implement this code in a mouse move event, the mouse jumps around to random locations on the screen.
So, I simplified the code so it only moves to the current mouse location. You should see no effect, but the mouse still jumps around the screen.
If 'r' is a Robot, then r.mouseMove(x, y) moves the cursor to the screen coordinates (x, y). The coordinates that you receive as arguments to the mouseEvent are coordinates relative to the panel origin (or the relevant component that has the MouseListener attached).
So, you have to translate the MouseEvent coordinates to Screen coordinates (use the method getLocationOnScreen)