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

public class MFXLoader extends Object
Convenience class for creating dashboards, no more hassle on managing multiple views.

This control makes use of LoaderUtils and it's capable of loading multiple FXML views with ExecutorServices.

The informations about a view are stored in bean classes, MFXLoaderBean. Those can be added to this loader by using the various "addView(...)" methods, and will be stored in a Map, every bean is associated to a String, which should be the identifier of the view, you can also use LoaderUtils.generateKey(URL) to automatically generate a key.

Once every view has been added you can start the loader with either start() or startWith(ExecutorService).

After all views have been loaded the onLoaded(List) method is called, see also setOnLoadedAction(Consumer).

This loader has two other notable features:

1) To load FXML files it uses a FXMLLoader of course. But, in some cases (like DI framework) you want to use a specific FXMLLoader, so the loader creates them with a Supplier, see fxmlLoaderSupplierProperty(). The default supplier is just "FXMLLoader::new", but you can easily change that if you need to.

2) To make the views ready for switching the loader can "preload" them (compute both CSS and Layout), you can manage this behavior by setting the "cache level", see setCacheLevel(LoaderCacheLevel) and LoaderCacheLevel

NOTE: the cache level must be set before invoking the start() method.

By default it is set to: LoaderCacheLevel.SCENE_CACHE

See Also: