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 the controller, before the initialize() method is called, the system looks for FXML elements...