- All Known Implementing Classes:
BaseFxmlAppDelegate
,NoopAppDelegate
public interface ApplicationDelegate
Interface for delegated JavaFX applications.
Supernaut.FX applications implement this interface.
Supernaut.FX applications implement this interface instead of subclassing JavaFX Application
. This has several
advantages over directly extending Application
:
- Supports flexible construction of application object hierarchies using Dependency Injection provided by Micronaut framework and possibly other D.I. frameworks in the future.
-
Applications
implement
aninterface
rather thanextend
aclass
. This increases the testability and architectural flexibility of the application. -
Supports faster, multi-threaded launching with the
FxLauncher
interface.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
init()
The application initialization method.default void
setApplication
(javafx.application.Application application) Pass the JavaFXApplication
to the delegate.void
start
(javafx.stage.Stage primaryStage) The main entry point for Supernaut.fx applications.default void
stop()
This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources.
-
Method Details
-
setApplication
Pass the JavaFXApplication
to the delegate. Override this method if your application needs access toHostServices
or other functionality available through theApplication
object.NOTE: This method will be called on the same thread as the JavaFX
Application
constructor.- Parameters:
application
- A reference to the delegating JavaFXApplication
instance
-
init
The application initialization method. This method is called from the JavaFXApplication.init()
method after the dependency injection context is initialized and the application is constructed and dependency injected.NOTE: This method is not called on the JavaFX Application Thread. An application must not construct a Scene or a Stage in this method. An application may construct other JavaFX objects in this method.
- Throws:
Exception
- if something goes wrong
-
start
The main entry point for Supernaut.fx applications. Called fromApplication.start(Stage)
. At a minimum, you must implement this method.NOTE: This method is called on the JavaFX Application Thread.
- Parameters:
primaryStage
- the primary stage- Throws:
Exception
- something went wrong
-
stop
This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources. Called fromApplication.stop()
NOTE: This method is called on the JavaFX Application Thread.
- Throws:
Exception
- if something goes wrong
-