Java Reference
In-Depth Information
Understanding the
FXMLLoader
Class
The
FXMLLoader
class has the following public constructors:
•
FXMLLoader()
•
FXMLLoader(URL location)
•
FXMLLoader(URL location, ResourceBundle resources)
•
FXMLLoader(URL location, ResourceBundle resources, BuilderFactory
builderFactory)
•
FXMLLoader(URL location, ResourceBundle resources, BuilderFactory BuilderFactory
builderFactory, Callback<Class<?>, Object> controllerFactory)
•
FXMLLoader(Charset charset)
•
FXMLLoader(URL location, ResourceBundle resources, BuilderFactory BuilderFactory
builderFactory, Callback<Class<?> controllerFactory, Object>, Charset charset)
•
FXMLLoader(URL location, ResourceBundle resources, BuilderFactory BuilderFactory
builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset,
LinkedList<FXMLLoader> loaders)
Constructors with fewer parameters delegate to constructors with more parameters, with the missing
parameters filled in with default values. The
location
parameter is the
URL
of the FXML file to be loaded. It
defaults to
null
. The
resources
parameter is the resource bundle to be used with the FXML file. This is necessary if
internationalized strings are used in the FXML file. It defaults to
null
. The
builderFactory
parameter is the builder
factory that
FXMLLoader
uses to get the builders of the various objects that it creates. It defaults to an instance of the
JavaFXBuilderFactory
. This builder factory has knowledge about all the standard JavaFX types that are likely to appear
in FXML files, so a customized builder factory is rarely used. The
controllerFactory
is a
javafx.util.CallBack
that is
capable of returning an instance of the controller when provided with the class of the controller. It defaults to
null
, in
which case the
FXMLLoader
will instantiate the controller through reflection by calling the no-parameters constructor
of the controller class. Therefore you need to supply a
controllerFactory
only if the controller cannot be constructed
that way. The
charset
is used when the FXML is parsed. It defaults to UTF-8. The
loaders
parameter is a list of
FXMLLoader
s. It defaults to an empty list.
The
FXMLLoader
class has the following getter and setter methods that alter the states of the
FXMLLoader
:
•
URL getLocation()
•
void setLocation(URL location)
•
ResourceBundle getResources()
•
void setResources(ResourceBundle resources)
•
ObservableMap<String, Object> getNamespace()
•
<T> T getRoot()
•
void setRoot(Object root)
•
<T> T getController()
•
void setController(Object controller)
•
BuilderFactory getBuilderFactory()
•
void setBuilderFactory(BuilderFactory builderFactory)
Search WWH ::
Custom Search