O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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"> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required