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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.