Module MaterialFX

Class LoaderUtils

java.lang.Object
io.github.palexdev.materialfx.utils.LoaderUtils

public class LoaderUtils extends Object
Utils class to load FXML views.
  • Method Details

    • submit

      public static Future<Parent> submit(Callable<Parent> task)
      Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

      If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

      Note: The Executors class includes a set of methods that can convert some other common closure-like objects, for example, PrivilegedAction to Callable form so they can be submitted.

      Parameters:
      task - the task to submit
      Returns:
      a Future representing pending completion of the task
      Throws:
      RejectedExecutionException - if the task cannot be scheduled for execution
      NullPointerException - if the task is null
    • fxmlLoad

      public static Parent fxmlLoad(MFXLoaderBean loaderBean) throws IOException
      Creates a new FXMLLoader with location MFXLoaderBean.getFxmlFile() and controller MFXLoaderBean.getControllerFactory() (if not null) and loads the fxml file.
      Returns:
      the loaded object hierarchy from the fxml
      Throws:
      IOException
      See Also:
      • fxmlLoad(FXMLLoader, URL)
      • fxmlLoad(FXMLLoader, URL, Callback)
    • fxmlLoad

      public static Parent fxmlLoad(FXMLLoader fxmlLoader, MFXLoaderBean loaderBean) throws IOException
      Sets the location and the controller factory (if not null) for the given fxmlLoader with MFXLoaderBean.getFxmlFile() and MFXLoaderBean.getControllerFactory(), and loads the fxml file.

      This method is useful for example when using a DI framework with JavaFX.
      Parameters:
      fxmlLoader - the FXMLLoader instance to use
      Returns:
      the loaded object hierarchy from the fxml
      Throws:
      IOException
      See Also:
      • fxmlLoad(FXMLLoader, URL)
      • fxmlLoad(FXMLLoader, URL, Callback)
    • checkFxmlFile

      public static void checkFxmlFile(URL fxmlFile)
      Check if the given URL is an fxml file.
    • generateKey

      public static String generateKey(URL fxmlFile)
      If no key is specified when calling 'addItem' then a default key is generated, corresponds to the fxml file name without the extension.
      Parameters:
      fxmlFile - The given fxml file
      Returns:
      The generated key