Narychlo:
import java.awt.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
Pane root = new Pane();
PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
int x = (int) b.getX();
int y = (int) b.getY();
root.addEventFilter(MouseEvent.MOUSE_MOVED, e -> {
try {
Robot robot = new Robot();
robot.mouseMove(x, y);
} catch (AWTException e1) {
e1.printStackTrace();
}
});
Scene scene = new Scene(root, 800, 400);
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
Bude to fungovat jen v okne te applikace a bude nekdy videt, jak se kurzor pohne a vrati zpet...