Using the JavaFX GUI framework
This version of the program is like the Swing version. The design of the user interface is identical in that it employs panes in panes. Here is the finished project layout:
Figure 13.7 – The JavaFX program layout
Let us now look at the classes from the JavaFX framework that we will need for our program.
Application
A JavaFX program must contain a class that extends Application
. Within this class, we can construct the user interface or delegate this work to another class. A class that extends Application
must implement a method called start
and, optionally, a method called init
. What you rarely have is a constructor. The JavaFX framework is not available to a constructor of a class that extends Application
. This is where init
comes in. It plays the role of the constructor but in an environment where JavaFX is up and running. You do not call init
; JavaFX will.
The start
method is where the creation of the GUI...