Interface ApplicationDelegate

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:

  1. Supports flexible construction of application object hierarchies using Dependency Injection provided by Micronaut framework and possibly other D.I. frameworks in the future.
  2. Applications implement an interface rather than extend a class. This increases the testability and architectural flexibility of the application.
  3. Supports faster, multi-threaded launching with the FxLauncher interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    The application initialization method.
    default void
    setApplication(javafx.application.Application application)
    Pass the JavaFX Application to the delegate.
    void
    start(javafx.stage.Stage primaryStage)
    The main entry point for Supernaut.fx applications.
    default void
    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

      default void setApplication(javafx.application.Application application)
      Pass the JavaFX Application to the delegate. Override this method if your application needs access to HostServices or other functionality available through the Application object.

      NOTE: This method will be called on the same thread as the JavaFX Application constructor.

      Parameters:
      application - A reference to the delegating JavaFX Application instance
    • init

      default void init() throws Exception
      The application initialization method. This method is called from the JavaFX Application.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

      void start(javafx.stage.Stage primaryStage) throws Exception
      The main entry point for Supernaut.fx applications. Called from Application.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

      default void stop() throws Exception
      This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources. Called from Application.stop()

      NOTE: This method is called on the JavaFX Application Thread.

      Throws:
      Exception - if something goes wrong