The most common way to use the JavaFX API is to subclass your application from the javafx.application.Application class. There are three overridable methods in there:
- public void init(): Overriding this method allows you to run code before the window is created. Usually, this method is used for loading resources, handling command-line parameters, and validating environments. If something is wrong at this stage, you can exit the program with a friendly command-line message without wasting resources on the window's creation.
Note this method is not called on JavaFX Application Thread, so you shouldn't construct any objects that are sensitive to it, such as Stage or Scene.
- public abstract void start(Stage stage): This is ...