How to do it...

  1. Create a simple class, RobotApplication that extends javafx.application.Application and sets up the UI required for testing the Robot API and also creates an instance of javafx.scene.robot.Robot. This class will be defined as a static inner class to the RobotAPIDemo main class :
public static class RobotApplication extends Application{  @Override  public void start(Stage stage) throws Exception{    robot = new Robot();    GridPane gridPane = new GridPane();    gridPane.setAlignment(Pos.CENTER);    gridPane.setHgap(10);    gridPane.setVgap(10);    gridPane.setPadding(new Insets(25, 25, 25, 25));    Text appTitle = new Text("Robot Demo");    appTitle.setFont(Font.font("Arial",         FontWeight.NORMAL, 15));    gridPane.add(appTitle, 0, 0, 2, 1); Label nameLbl ...

Get Java 11 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.