Module MaterialFX

Class MFXLoaderBean

java.lang.Object
io.github.palexdev.materialfx.utils.others.loader.MFXLoaderBean

public class MFXLoaderBean extends Object
Support bean for MFXLoader to define the properties of a view such as:

- An identifier for the view

- The FXML file of the view

- The root node of the FXML (managed by the loader, set once the view is loaded)

- The controller factory in case the controller uses parameterized constructors (optional)

- A flag to indicate whether this view should be considered the default one (useful for nav-bars/dashboards)

- A flag to indicate whether the view has been loaded (managed by the loader, set to true once the view is loaded)

- A Supplier function to convert the bean to a Node. This is useful for example in case you want to implement a view switcher, you could produce a Button or any node you want that will handle the view switching, for a concrete example you could see the MaterialFX's DemoController (in the demo module).

The bean also offers a MFXLoaderBean.Builder with fluent api, it's suggested to use that instead of constructors.

You can also access the builder with the provided static method of(String, URL).

  • Constructor Details

  • Method Details

    • of

      public static MFXLoaderBean.Builder of(String viewName, URL fxmlFile)
    • getViewName

      public String getViewName()
      Returns:
      the view's identifier
    • getFxmlFile

      public URL getFxmlFile()
      Returns:
      the view's FXML file
    • getRoot

      public Parent getRoot()
      Returns:
      the FXML file's root node
    • getControllerFactory

      public Callback<Class<?>,Object> getControllerFactory()
      Returns:
      the callback used to produce the view's controller
    • setControllerFactory

      public MFXLoaderBean setControllerFactory(Callback<Class<?>,Object> controllerFactory)
      Sets the callback used to produce the view's controller.
    • isDefaultView

      public boolean isDefaultView()
      Returns:
      whether this view should be considered the default view
    • setDefaultView

      public MFXLoaderBean setDefaultView(boolean defaultView)
      Sets whether this view should be considered the default view.
    • isLoaded

      public boolean isLoaded()
      Returns:
      whether the view has been loaded by the loader
    • getBeanToNodeMapper

      public Supplier<Node> getBeanToNodeMapper()
      Returns:
      the supplier used to convert this view into a Node
    • setBeanToNodeMapper

      public MFXLoaderBean setBeanToNodeMapper(Supplier<Node> beanToNodeMapper)
      Sets the supplier used to convert this view into a Node.