Javafx Robot not working from Javafx 2.2


Question

Looks like com.sun.glass.ui.Robot is not working anymore in Javafx 2.2.

Is there any other alternative?

I've moved over to AWT robot, but that does not seem to be the best solution.

1
2
8/28/2012 12:10:54 PM

Accepted Answer

Glass (FX) robot works for me in 2.2. Try next:

public void start(Stage stage) {
    Button btn = new Button();
    btn.setText("Button");
    btn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });

    Scene scene = new Scene(new Group(btn), 300, 250);

    stage.setTitle(VersionInfo.getRuntimeVersion());
    stage.setScene(scene);
    stage.setX(100);
    stage.setY(100);
    stage.show();

    Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
    robot.mouseMove(130, 130);
    robot.mousePress(1);
    robot.mouseRelease(1);
}

If you want public API for it to be added you can vote for next issue: http://javafx-jira.kenai.com/browse/RT-17571

5
8/14/2012 12:04:16 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon