Let’s write your first JavaFX application. It should display the text “Hello JavaFX” in a window. I will take an incremental, step-by-step approach to explain how to develop this first application. I will add as few lines of code as possible, and then, explain what the code does and why it is needed.
Creating the HelloJavaFX Class
A JavaFX application is a class that must inherit from the Application class that is in the
javafx.application package. You will name your class HelloFXApp and it will be stored in the com.jdojo.intro package. Listing 1 shows the initial code for the HelloFXApp class. Note that the HelloFXApp class will not compile at this point. You will fix it in the next section.