Initializing the user interface

While the FXML defines the structure of the user interface, we do need some Java code to initialize various elements, respond to actions, and so forth. This class, referred to as the controller, is simply a class that extends javafx.fxml.Initializable:

    public class Controller implements Initializable { 
      @FXML 
      private TableView<ProcessHandle> processList; 
      @Override 
      public void initialize(URL url, ResourceBundle rb) { 
      } 
    } 

The initialize() method comes from the interface, and is used by the JavaFX runtime to initialize the controller when it is created in the call to FXMLLoader.load() from the preceding Application class. Note the @FXML annotation on the instance variable processList. When JavaFX initializes ...

Get Java 9 Programming Blueprints 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.