Class FulibFxApp
-
Nested Class Summary
Nested classes/interfaces inherited from class javafx.application.Application
javafx.application.Application.Parameters -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.reactivex.rxjava3.core.Schedulerstatic final LoggerFields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns auto refresher of the application.voidback()Returns to the previous controller in the history if possible.protected voidcleanup()<T extends javafx.scene.Parent>
Tdestroy(T rendered) Destroys a rendered controller extending Parent.protected voiddisplay(@NotNull javafx.scene.Parent parent) Displays the given parent.formatTitle(String title) Formats the title of a controller using the title pattern.voidforward()Forwards to the next controller in the history if possible.Returns the currently used component of the application.Returns the title of the given controller.<T extends javafx.scene.Parent>
TinitAndRender(@NotNull String route) Initializes and renders the component with the given route.<T extends javafx.scene.Parent>
TinitAndRender(@NotNull String route, @NotNull Map<@NotNull String, @Nullable Object> params) Initializes and renders the component with the given route.<T extends javafx.scene.Parent>
TinitAndRender(@NotNull String route, @NotNull Map<@NotNull String, @Nullable Object> params, @Nullable io.reactivex.rxjava3.disposables.DisposableContainer onDestroy) Initializes and renders the component with the given route.<T extends javafx.scene.Parent>
TinitAndRender(T component) Initializes and renders a component instance (a controller with theComponentannotation).<T extends javafx.scene.Parent>
TinitAndRender(T component, @NotNull Map<@NotNull String, @Nullable Object> params) Initializes and renders a component instance (a controller with theComponentannotation).<T extends javafx.scene.Parent>
TinitAndRender(T component, @NotNull Map<@NotNull String, @Nullable Object> params, @Nullable io.reactivex.rxjava3.disposables.DisposableContainer onDestroy) Initializes and renders a component instance (a controller with theComponentannotation).protected voidonShow(Optional<String> route, Object controller, javafx.scene.Parent rendered, Map<String, Object> params) Called when the application shows a new controller.voidrefresh()Refreshes the current controller.voidregisterRoutes(Object routes) Registers all routes in the given class.static @NotNull PathReturns the path to the 'resources' directory.voidsetDefaultResourceBundle(ResourceBundle resourceBundle) Sets the default resource bundle to use for FXML files if no resource bundle is provided in the controller/component.voidsetHistorySize(int size) Sets the history size of the application.static voidsetResourcesPath(@NotNull Path path) Sets the path to the 'resources' directory.voidsetTitlePattern(String titlePattern) Sets the title pattern for the application.voidsetTitlePattern(Function<String, String> titlePattern) Sets the title pattern for the application.@NotNull javafx.scene.ParentInitializes, renders and displays a controller.@NotNull javafx.scene.ParentInitializes, renders and displays a controller.@NotNull javafx.scene.ParentInitializes, renders and displays a controller.@NotNull javafx.scene.ParentInitializes, renders and displays a controller.javafx.stage.Stagestage()Returns the stage of the application.voidstart(javafx.stage.Stage primaryStage) voidstop()Methods inherited from class javafx.application.Application
getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet
-
Field Details
-
FX_SCHEDULER
public static final io.reactivex.rxjava3.core.Scheduler FX_SCHEDULER -
LOGGER
-
-
Constructor Details
-
FulibFxApp
public FulibFxApp()
-
-
Method Details
-
resourcesPath
Returns the path to the 'resources' directory.- Returns:
- The path to the resources directory
-
setResourcesPath
Sets the path to the 'resources' directory. If your 'resources' directory differs from "src/main/resources", you can set it here.If your project is contained in another directory (e.g. gradle submodule), you can set the path to the 'resources' directory here.
- Parameters:
path- The path to the resources directory (e.g. "example/src/main/resources")
-
initAndRender
Initializes and renders the component with the given route.The component has to be destroyed manually, for example by calling
destroy(Parent).- Type Parameters:
T- The type of the component- Parameters:
route- The route of the component to render- Returns:
- The rendered component
-
initAndRender
@NotNull public <T extends javafx.scene.Parent> T initAndRender(@NotNull T component) Initializes and renders a component instance (a controller with theComponentannotation).The component has to be destroyed manually, for example by calling
destroy(Parent).- Type Parameters:
T- The type of the component- Parameters:
component- The component instance- Returns:
- The rendered component
-
initAndRender
@NotNull public <T extends javafx.scene.Parent> T initAndRender(@NotNull @NotNull String route, @NotNull @NotNull Map<@NotNull String, @Nullable Object> params) Initializes and renders the component with the given route.The component has to be destroyed manually, for example by calling
destroy(Parent).- Type Parameters:
T- The type of the component- Parameters:
route- The route of the component to renderparams- The arguments passed to the component- Returns:
- The rendered component
-
initAndRender
@NotNull public <T extends javafx.scene.Parent> T initAndRender(@NotNull T component, @NotNull @NotNull Map<@NotNull String, @Nullable Object> params) Initializes and renders a component instance (a controller with theComponentannotation).The component has to be destroyed manually, for example by calling
destroy(Parent).- Type Parameters:
T- The type of the component- Parameters:
component- The component instanceparams- The arguments passed to the component- Returns:
- The rendered component
-
initAndRender
@NotNull public <T extends javafx.scene.Parent> T initAndRender(@NotNull @NotNull String route, @NotNull @NotNull Map<@NotNull String, @Nullable Object> params, @Nullable @Nullable io.reactivex.rxjava3.disposables.DisposableContainer onDestroy) Initializes and renders the component with the given route.If a disposable is provided, the disposable will be modified to include the cleanup of the rendered component. The provided disposable can be used to destroy the component with all its children manually.
If no disposable is provided, the component has to be destroyed manually, for example by calling
destroy(Parent).- Type Parameters:
T- The type of the component- Parameters:
route- The route of the component to renderparams- The arguments passed to the componentonDestroy- A disposable which will be modified to include the disposable of the component- Returns:
- The rendered component
-
initAndRender
@NotNull public <T extends javafx.scene.Parent> T initAndRender(@NotNull T component, @NotNull @NotNull Map<@NotNull String, @Nullable Object> params, @Nullable @Nullable io.reactivex.rxjava3.disposables.DisposableContainer onDestroy) Initializes and renders a component instance (a controller with theComponentannotation).If a disposable is provided, the disposable will be modified to include the cleanup of the rendered component. The provided disposable can be used to destroy the component with all its children manually.
If no disposable is provided, the component has to be destroyed manually, for example by calling
destroy(Parent).- Parameters:
component- The component instanceparams- The arguments passed to the componentonDestroy- A disposable which will be modified to include the disposable of the component- Returns:
- The rendered component
-
destroy
@NotNull public <T extends javafx.scene.Parent> T destroy(@NotNull T rendered) Destroys a rendered controller extending Parent.- Type Parameters:
T- The type of the controller- Parameters:
rendered- The rendered controller instance- Returns:
- The destroyed controller instance
- Throws:
IllegalArgumentException- If the given instance is not a controller extending Parent
-
start
@MustBeInvokedByOverriders public void start(javafx.stage.Stage primaryStage) - Specified by:
startin classjavafx.application.Application
-
stop
public void stop()- Overrides:
stopin classjavafx.application.Application
-
show
Initializes, renders and displays a controller.- Parameters:
route- The route of the controller to render- Returns:
- The rendered parent of the controller
-
show
Initializes, renders and displays a controller.- Parameters:
controller- The controller to render- Returns:
- The rendered parent of the controller
-
show
@NotNull public @NotNull javafx.scene.Parent show(@NotNull @NotNull Object controller, @NotNull @NotNull Map<String, Object> params) Initializes, renders and displays a controller.- Parameters:
controller- The controller to renderparams- The arguments passed to the controller- Returns:
- The rendered parent of the controller
-
show
@NotNull public @NotNull javafx.scene.Parent show(@NotNull @NotNull String route, @NotNull @NotNull Map<@NotNull String, @Nullable Object> params) Initializes, renders and displays a controller.- Parameters:
route- The route of the controller to renderparams- The arguments passed to the controller- Returns:
- The rendered parent of the controller
-
display
protected void display(@NotNull @NotNull javafx.scene.Parent parent) Displays the given parent. Will be called when showing a main controller or when reloading the currently displayed controller. This method can be overridden to add custom behavior like multiple controllers on top of each other.- Parameters:
parent- The parent to display
-
cleanup
protected void cleanup() -
onShow
protected void onShow(Optional<String> route, Object controller, javafx.scene.Parent rendered, Map<String, Object> params) Called when the application shows a new controller.This method is called after the controller is initialized and rendered.
- Parameters:
route- The route of the controller (empty if the controller has been shown directly)controller- The controller instancerendered- The rendered parent of the controllerparams- The arguments passed to the controller
-
stage
public javafx.stage.Stage stage()Returns the stage of the application.- Returns:
- The stage of the application
-
frameworkComponent
Returns the currently used component of the application.Warning: This method should only be used for internal purposes.
- Returns:
- The component
-
registerRoutes
Registers all routes in the given class.- Parameters:
routes- The class to register the routes from
-
setDefaultResourceBundle
Sets the default resource bundle to use for FXML files if no resource bundle is provided in the controller/component. -
autoRefresher
Returns auto refresher of the application. -
back
public void back()Returns to the previous controller in the history if possible. -
forward
public void forward()Forwards to the next controller in the history if possible. -
refresh
public void refresh()Refreshes the current controller.The controller will be cleaned up and then re-initialized and re-rendered. This method will re-use the current route and parameters and not update the history.
-
setTitlePattern
Sets the title pattern for the application. This title pattern expects a function that will be called with the title of the controller and should return the final title.- Parameters:
titlePattern- The title pattern
-
setTitlePattern
Sets the title pattern for the application. This title pattern expects a '%s' placeholder which will be replaced with the title of the controller.- Parameters:
titlePattern- The title pattern
-
formatTitle
Formats the title of a controller using the title pattern.- Parameters:
title- The title of the controller- Returns:
- The formatted title
-
getTitle
Returns the title of the given controller.- Parameters:
controller- The controller instance- Returns:
- The title of the controller
-
setHistorySize
public void setHistorySize(int size) Sets the history size of the application.The smaller the history size, the less memory is used.
The larger the history size, the more controllers can be navigated back and forth.
The default history size is 10. It cannot be smaller than 1.
- Parameters:
size- The history size
-