java.lang.Object
javafx.fxml.FXMLLoader
Loads an object hierarchy from an XML document.
 For more information, see the
 Introduction to FXML
 document.
- Since:
- JavaFX 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDelimiter for arrays as values.static final StringPrefix for bidirectional-binding expression resolution.static final StringSuffix for bidirectional-binding expression resolution.static final StringPrefix for binding expression resolution.static final StringSuffix for binding expression resolution.static final StringSuffix for property change/invalidation handlers.static final StringThe tag name of the compile processing instruction.static final StringA key for controller in namespace map.static final StringPrefix for controller method resolution.static final StringA suffix for controllers of included fxml files.static final StringThe <fx:copy> 'source' attribute.static final StringThe tag name of <fx:copy>.static final StringThe character set used when character set is not explicitly specified.static final StringThe tag name of <fx:define>.static final StringEscape prefix for escaping special characters inside attribute values.static final StringThe prefix of event handler attributes.static final StringThe name of the Event object in event handler scripts.static final StringPrefix for (variable) expression resolution.static final StringThe tag name of 'fx:constant'.static final StringThe name of fx:controller attribute of a root.static final StringThe name of 'fx:factory' attribute.static final StringThe name of fx:id attribute.static final StringPrefix of 'fx' namespace.static final StringContains the current fx namepsace version.static final StringThe name of fx:value attribute.static final StringThe tag name of import processing instruction.static final StringThe <fx:include> 'charset' attribute.static final StringThe <fx:include> 'resources' attribute.static final StringThe <fx:include> 'source' attribute.static final StringThe tag name of <fx:include>.static final StringThe name of initialize method.static final StringContains the current javafx version.static final StringThe tag name of language processing instruction.static final StringA key for location URL in namespace map.static final StringValue that represents 'null'.static final StringThe <fx:reference> 'source' attribute.static final StringThe tag name of <fx:reference>.static final StringPrefix for relative location resolution.static final StringPrefix for resource resolution.static final StringA key for ResourceBundle in namespace map.static final StringThe tag name of <fx:root>.static final StringThe <fx:root> 'type' attribute.static final StringThe <fx:script> 'charset' attribute.static final StringThe <fx:script> 'source' attribute.static final StringThe tag name of <fx:script>.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new FXMLLoader instance.FXMLLoader(URL location) Creates a new FXMLLoader instance.FXMLLoader(URL location, ResourceBundle resources) Creates a new FXMLLoader instance.FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory) Creates a new FXMLLoader instance.FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory) Creates a new FXMLLoader instance.FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset) Creates a new FXMLLoader instance.FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset, LinkedList<FXMLLoader> loaders) Creates a new FXMLLoader instance.FXMLLoader(Charset charset) Creates a new FXMLLoader instance.
- 
Method SummaryModifier and TypeMethodDescriptionReturns the builder factory used by this loader.Returns the character set used by this loader.Returns the classloader used by this loader.<T> TReturns the controller associated with the root object.Returns the controller factory used by this loader.static ClassLoaderReturns the default class loader.Returns this loader's load listener.Returns the location used to resolve relative path attribute values.Returns the namespace used by this loader.Returns the resources used to resolve resource key attribute values.<T> TgetRoot()Returns the root of the object hierarchy.<T> Tload()Loads an object hierarchy from a FXML document.<T> Tload(InputStream inputStream) Loads an object hierarchy from a FXML document.static <T> TLoads an object hierarchy from a FXML document.static <T> Tload(URL location, ResourceBundle resources) Loads an object hierarchy from a FXML document.static <T> Tload(URL location, ResourceBundle resources, BuilderFactory builderFactory) Loads an object hierarchy from a FXML document.static <T> Tload(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory) Loads an object hierarchy from a FXML document.static <T> Tload(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset) Loads an object hierarchy from a FXML document.static Class<?>Deprecated.static Class<?>Deprecated.This method now delegates togetDefaultClassLoader().voidsetBuilderFactory(BuilderFactory builderFactory) Sets the builder factory used by this loader.voidsetCharset(Charset charset) Sets the character set used by this loader.voidsetClassLoader(ClassLoader classLoader) Sets the classloader used by this loader and clears any existing imports.voidsetController(Object controller) Sets the controller associated with the root object.voidsetControllerFactory(Callback<Class<?>, Object> controllerFactory) Sets the controller factory used by this loader.static voidsetDefaultClassLoader(ClassLoader defaultClassLoader) Sets the default class loader.final voidsetLoadListener(LoadListener loadListener) Sets this loader's load listener.voidsetLocation(URL location) Sets the location used to resolve relative path attribute values.voidsetResources(ResourceBundle resources) Sets the resources used to resolve resource key attribute values.voidSets the root of the object hierarchy.
- 
Field Details- 
DEFAULT_CHARSET_NAMEThe character set used when character set is not explicitly specified.- See Also:
 
- 
LANGUAGE_PROCESSING_INSTRUCTIONThe tag name of language processing instruction.- See Also:
 
- 
IMPORT_PROCESSING_INSTRUCTIONThe tag name of import processing instruction.- See Also:
 
- 
COMPILE_PROCESSING_INSTRUCTIONThe tag name of the compile processing instruction.- Since:
- 15
- See Also:
 
- 
FX_NAMESPACE_PREFIXPrefix of 'fx' namespace.- See Also:
 
- 
FX_CONTROLLER_ATTRIBUTEThe name of fx:controller attribute of a root.- See Also:
 
- 
FX_ID_ATTRIBUTEThe name of fx:id attribute.- See Also:
 
- 
FX_VALUE_ATTRIBUTEThe name of fx:value attribute.- See Also:
 
- 
FX_CONSTANT_ATTRIBUTEThe tag name of 'fx:constant'.- Since:
- JavaFX 2.2
- See Also:
 
- 
FX_FACTORY_ATTRIBUTEThe name of 'fx:factory' attribute.- See Also:
 
- 
INCLUDE_TAGThe tag name of <fx:include>.- See Also:
 
- 
INCLUDE_SOURCE_ATTRIBUTEThe <fx:include> 'source' attribute.- See Also:
 
- 
INCLUDE_RESOURCES_ATTRIBUTEThe <fx:include> 'resources' attribute.- See Also:
 
- 
INCLUDE_CHARSET_ATTRIBUTEThe <fx:include> 'charset' attribute.- See Also:
 
- 
SCRIPT_TAGThe tag name of <fx:script>.- See Also:
 
- 
SCRIPT_SOURCE_ATTRIBUTEThe <fx:script> 'source' attribute.- See Also:
 
- 
SCRIPT_CHARSET_ATTRIBUTEThe <fx:script> 'charset' attribute.- See Also:
 
- 
DEFINE_TAGThe tag name of <fx:define>.- See Also:
 
- 
REFERENCE_TAGThe tag name of <fx:reference>.- See Also:
 
- 
REFERENCE_SOURCE_ATTRIBUTEThe <fx:reference> 'source' attribute.- See Also:
 
- 
ROOT_TAGThe tag name of <fx:root>.- Since:
- JavaFX 2.2
- See Also:
 
- 
ROOT_TYPE_ATTRIBUTEThe <fx:root> 'type' attribute.- Since:
- JavaFX 2.2
- See Also:
 
- 
COPY_TAGThe tag name of <fx:copy>.- See Also:
 
- 
COPY_SOURCE_ATTRIBUTEThe <fx:copy> 'source' attribute.- See Also:
 
- 
EVENT_HANDLER_PREFIXThe prefix of event handler attributes.- See Also:
 
- 
EVENT_KEYThe name of the Event object in event handler scripts.- See Also:
 
- 
CHANGE_EVENT_HANDLER_SUFFIXSuffix for property change/invalidation handlers.- See Also:
 
- 
NULL_KEYWORDValue that represents 'null'.- See Also:
 
- 
ESCAPE_PREFIXEscape prefix for escaping special characters inside attribute values. Serves as an escape forESCAPE_PREFIX,RELATIVE_PATH_PREFIX,RESOURCE_KEY_PREFIX,EXPRESSION_PREFIX,BI_DIRECTIONAL_BINDING_PREFIX- Since:
- JavaFX 2.1
- See Also:
 
- 
RELATIVE_PATH_PREFIXPrefix for relative location resolution.- See Also:
 
- 
RESOURCE_KEY_PREFIXPrefix for resource resolution.- See Also:
 
- 
EXPRESSION_PREFIXPrefix for (variable) expression resolution.- See Also:
 
- 
BINDING_EXPRESSION_PREFIXPrefix for binding expression resolution.- See Also:
 
- 
BINDING_EXPRESSION_SUFFIXSuffix for binding expression resolution.- See Also:
 
- 
BI_DIRECTIONAL_BINDING_PREFIXPrefix for bidirectional-binding expression resolution.- Since:
- JavaFX 2.1
- See Also:
 
- 
BI_DIRECTIONAL_BINDING_SUFFIXSuffix for bidirectional-binding expression resolution.- Since:
- JavaFX 2.1
- See Also:
 
- 
ARRAY_COMPONENT_DELIMITERDelimiter for arrays as values.- Since:
- JavaFX 2.1
- See Also:
 
- 
LOCATION_KEYA key for location URL in namespace map.- Since:
- JavaFX 2.2
- See Also:
 
- 
RESOURCES_KEYA key for ResourceBundle in namespace map.- Since:
- JavaFX 2.2
- See Also:
 
- 
CONTROLLER_METHOD_PREFIXPrefix for controller method resolution.- See Also:
 
- 
CONTROLLER_KEYWORDA key for controller in namespace map.- Since:
- JavaFX 2.1
- See Also:
 
- 
CONTROLLER_SUFFIXA suffix for controllers of included fxml files. The full key is stored in namespace map.- Since:
- JavaFX 2.2
- See Also:
 
- 
INITIALIZE_METHOD_NAMEThe name of initialize method.- Since:
- JavaFX 2.2
- See Also:
 
- 
JAVAFX_VERSIONContains the current javafx version.- Since:
- JavaFX 8.0
 
- 
FX_NAMESPACE_VERSIONContains the current fx namepsace version.- Since:
- JavaFX 8.0
- See Also:
 
 
- 
- 
Constructor Details- 
FXMLLoaderpublic FXMLLoader()Creates a new FXMLLoader instance.
- 
FXMLLoaderCreates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- Since:
- JavaFX 2.1
 
- 
FXMLLoaderCreates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- resources- the resources used to resolve resource key attribute values
- Since:
- JavaFX 2.1
 
- 
FXMLLoaderCreates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- resources- resources used to resolve resource key attribute values
- builderFactory- the builder factory used by this loader
- Since:
- JavaFX 2.1
 
- 
FXMLLoaderpublic FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory) Creates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- resources- resources used to resolve resource key attribute values
- builderFactory- the builder factory used by this loader
- controllerFactory- the controller factory used by this loader
- Since:
- JavaFX 2.1
 
- 
FXMLLoaderCreates a new FXMLLoader instance.- Parameters:
- charset- the character set used by this loader
 
- 
FXMLLoaderpublic FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset) Creates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- resources- resources used to resolve resource key attribute values
- builderFactory- the builder factory used by this loader
- controllerFactory- the controller factory used by this loader
- charset- the character set used by this loader
- Since:
- JavaFX 2.1
 
- 
FXMLLoaderpublic FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset, LinkedList<FXMLLoader> loaders) Creates a new FXMLLoader instance.- Parameters:
- location- the location used to resolve relative path attribute values
- resources- resources used to resolve resource key attribute values
- builderFactory- the builder factory used by this loader
- controllerFactory- the controller factory used by this loader
- charset- the character set used by this loader
- loaders- list of loaders
- Since:
- JavaFX 2.1
 
 
- 
- 
Method Details- 
getLocationReturns the location used to resolve relative path attribute values.- Returns:
- the location used to resolve relative path attribute values
 
- 
setLocationSets the location used to resolve relative path attribute values.- Parameters:
- location- the location
 
- 
getResourcesReturns the resources used to resolve resource key attribute values.- Returns:
- the resources used to resolve resource key attribute values
 
- 
setResourcesSets the resources used to resolve resource key attribute values.- Parameters:
- resources- the resources
 
- 
getNamespaceReturns the namespace used by this loader.- Returns:
- the namespace
 
- 
getRootpublic <T> T getRoot()Returns the root of the object hierarchy.- Type Parameters:
- T- the type of the root object
- Returns:
- the root of the object hierarchy
 
- 
setRootSets the root of the object hierarchy. The value passed to this method is used as the value of the<fx:root>tag. This method must be called prior to loading the document when using<fx:root>.- Parameters:
- root- the root of the object hierarchy
- Since:
- JavaFX 2.2
 
- 
getControllerpublic <T> T getController()Returns the controller associated with the root object.- Type Parameters:
- T- the type of the controller
- Returns:
- the controller associated with the root object
 
- 
setControllerSets the controller associated with the root object. The value passed to this method is used as the value of thefx:controllerattribute. This method must be called prior to loading the document when using controller event handlers when anfx:controllerattribute is not specified in the document.- Parameters:
- controller- the controller to associate with the root object
- Since:
- JavaFX 2.2
 
- 
getBuilderFactoryReturns the builder factory used by this loader.- Returns:
- the builder factory
 
- 
setBuilderFactorySets the builder factory used by this loader.- Parameters:
- builderFactory- the builder factory
 
- 
getControllerFactoryReturns the controller factory used by this loader.- Returns:
- the controller factory
- Since:
- JavaFX 2.1
 
- 
setControllerFactorySets the controller factory used by this loader.- Parameters:
- controllerFactory- the controller factory
- Since:
- JavaFX 2.1
 
- 
getCharsetReturns the character set used by this loader.- Returns:
- the character set
 
- 
setCharsetSets the character set used by this loader.- Parameters:
- charset- the character set
- Since:
- JavaFX 2.1
 
- 
getClassLoaderReturns the classloader used by this loader.- Returns:
- the classloader
- Since:
- JavaFX 2.1
 
- 
setClassLoaderSets the classloader used by this loader and clears any existing imports.- Parameters:
- classLoader- the classloader
- Since:
- JavaFX 2.1
 
- 
getLoadListenerReturns this loader's load listener.- Returns:
- the load listener
- Since:
- 9
 
- 
setLoadListenerSets this loader's load listener.- Parameters:
- loadListener- the load listener
- Since:
- 9
 
- 
loadLoads an object hierarchy from a FXML document. The location from which the document will be loaded must have been set by a prior call tosetLocation(URL).- Type Parameters:
- T- the type of the root object
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
- Since:
- JavaFX 2.1
 
- 
loadLoads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- inputStream- an input stream containing the FXML data to load
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
 
- 
loadType@Deprecated public static Class<?> loadType(String packageName, String className) throws ClassNotFoundException Deprecated.This method now delegates togetDefaultClassLoader().Loads a type using the default class loader.- Parameters:
- packageName- the package name of the class to load
- className- the name of the class to load
- Returns:
- the class
- Throws:
- ClassNotFoundException- if the specified class cannot be found
 
- 
loadTypeDeprecated.This method now delegates togetDefaultClassLoader().Loads a type using the default class loader.- Parameters:
- className- the name of the class to load
- Returns:
- the class
- Throws:
- ClassNotFoundException- if the specified class cannot be found
 
- 
getDefaultClassLoaderReturns the default class loader.- Returns:
- the default class loader
- Since:
- JavaFX 2.1
 
- 
setDefaultClassLoaderSets the default class loader.- Parameters:
- defaultClassLoader- The default class loader to use when loading classes.
- Since:
- JavaFX 2.1
 
- 
loadLoads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- location- the location used to resolve relative path attribute values
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
 
- 
loadLoads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- location- the location used to resolve relative path attribute values
- resources- the resources used to resolve resource key attribute values
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
 
- 
loadpublic static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory) throws IOException Loads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- location- the location used to resolve relative path attribute values
- resources- the resources used to resolve resource key attribute values
- builderFactory- the builder factory used to load the document
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
 
- 
loadpublic static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory) throws IOExceptionLoads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- location- the location used to resolve relative path attribute values
- resources- the resources used to resolve resource key attribute values
- builderFactory- the builder factory used when loading the document
- controllerFactory- the controller factory used when loading the document
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
- Since:
- JavaFX 2.1
 
- 
loadpublic static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>, Object> controllerFactory, Charset charset) throws IOExceptionLoads an object hierarchy from a FXML document.- Type Parameters:
- T- the type of the root object
- Parameters:
- location- the location used to resolve relative path attribute values
- resources- the resources used to resolve resource key attribute values
- builderFactory- the builder factory used when loading the document
- controllerFactory- the controller factory used when loading the document
- charset- the character set used when loading the document
- Returns:
- the loaded object hierarchy
- Throws:
- IOException- if an error occurs during loading
- Since:
- JavaFX 2.1
 
 
- 
getDefaultClassLoader().