内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
如何制作一个应用程序,它可以测量光标与组件中心的距离,然后将光标移回中心?
示例代码:
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) { }