2012-08-14 81 views

回答

5

玻璃(FX)機器人爲我工作在2.2。嘗試下:

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); 
} 

如果你想公開API爲它加入你可以投票給下一個問題:http://javafx-jira.kenai.com/browse/RT-17571

+0

謝謝謝爾蓋,我已經投了吉拉的功能 – betaman 2012-08-14 13:20:03