简体   繁体   中英

How to control (move) the mouse cursor?

How do I move the mouse cursor (windows) with Java? I have a pair of values constantly being updated. I want to use them to control the cursor.

You will need to use the Robot class.

Robot r = null;
try {
    r = new Robot();
} catch (AWTException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
r.mouseMove(x, y);//x is the horizontal position on the screen, y is the vertical

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM