Moving the cursor in Java

Robot class can do the trick for you. Here is a sample code for moving the mouse cursor:

try {
    // These coordinates are screen coordinates
    int xCoord = 500;
    int yCoord = 500;

    // Move the cursor
    Robot robot = new Robot();
    robot.mouseMove(xCoord, yCoord);
} catch (AWTException e) {
}

Leave a Comment