How to do it...

  1. All the FXML files should end with the .fxml extension. Let's create an empty fxml_age_calc_gui.xml file in the location src/gui/com/packt. In the subsequent steps, we will update this file with the XML tags for the JavaFX components.
  2. Create a GridPane layout, which will hold all the components in a grid of rows and columns. We will also provide the required spacing between the rows and the columns using the vgap and hgap attributes. Also, we will provide GridPane, which is our root component, with the reference to the Java class, where we will add the required event handling. This Java class will be like the controller for the UI:
 <GridPane alignment="CENTER" hgap="10.0" vgap="10.0" xmlns:fx="http://javafx.com/fxml" fx:controller="com.packt.FxmlController"> ...

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.