- java.lang.Object
-
- javafx.fxml.FXMLLoader
-
public class FXMLLoader extends Object
Loads an object hierarchy from an XML document.- Since:
- JavaFX 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
ARRAY_COMPONENT_DELIMITER
Delimiter for arrays as valuesstatic String
BI_DIRECTIONAL_BINDING_PREFIX
Prefix for bidirectional-binding expression resolutionstatic String
BI_DIRECTIONAL_BINDING_SUFFIX
Suffix for bidirectional-binding expression resolutionstatic String
BINDING_EXPRESSION_PREFIX
Prefix for binding expression resolutionstatic String
BINDING_EXPRESSION_SUFFIX
Suffix for binding expression resolutionstatic String
CHANGE_EVENT_HANDLER_SUFFIX
Suffix for property change/invalidation handlersstatic String
CONTROLLER_KEYWORD
A key for controller in namespace mapstatic String
CONTROLLER_METHOD_PREFIX
Prefix for controller method resolutionstatic String
CONTROLLER_SUFFIX
A suffix for controllers of included fxml files.static String
COPY_SOURCE_ATTRIBUTE
<fx:copy> 'source' attributestatic String
COPY_TAG
The tag name of <fx:copy>static String
DEFAULT_CHARSET_NAME
The character set used when character set is not explicitly specifiedstatic String
DEFINE_TAG
The tag name of <fx:define>static String
ESCAPE_PREFIX
Escape prefix for escaping special characters inside attribute values.static String
EVENT_HANDLER_PREFIX
The prefix of event handler attributesstatic String
EVENT_KEY
The name of the Event object in event handler scriptsstatic String
EXPRESSION_PREFIX
Prefix for (variable) expression resolutionstatic String
FX_CONSTANT_ATTRIBUTE
The tag name of 'fx:constant'static String
FX_CONTROLLER_ATTRIBUTE
The name of fx:controller attribute of a rootstatic String
FX_FACTORY_ATTRIBUTE
The name of 'fx:factory' attributestatic String
FX_ID_ATTRIBUTE
The name of fx:id attributestatic String
FX_NAMESPACE_PREFIX
Prefix of 'fx' namespacestatic String
FX_NAMESPACE_VERSION
Contains the current fx namepsace versionstatic String
FX_VALUE_ATTRIBUTE
The name of fx:value attributestatic String
IMPORT_PROCESSING_INSTRUCTION
The tag name of import processing instructionstatic String
INCLUDE_CHARSET_ATTRIBUTE
<fx:include> 'charset' attributestatic String
INCLUDE_RESOURCES_ATTRIBUTE
<fx:include> 'resources' attributestatic String
INCLUDE_SOURCE_ATTRIBUTE
<fx:include> 'source' attributestatic String
INCLUDE_TAG
The tag name of <fx:include>static String
INITIALIZE_METHOD_NAME
The name of initialize methodstatic String
JAVAFX_VERSION
Contains the current javafx versionstatic String
LANGUAGE_PROCESSING_INSTRUCTION
The tag name of language processing instructionstatic String
LOCATION_KEY
A key for location URL in namespace mapstatic String
NULL_KEYWORD
Value that represents 'null'static String
REFERENCE_SOURCE_ATTRIBUTE
<fx:reference> 'source' attributestatic String
REFERENCE_TAG
The tag name of <fx:reference>static String
RELATIVE_PATH_PREFIX
Prefix for relative location resultionstatic String
RESOURCE_KEY_PREFIX
Prefix for resource resolutionstatic String
RESOURCES_KEY
A key for ResourceBundle in namespace mapstatic String
ROOT_TAG
The tag name of <fx:root>static String
ROOT_TYPE_ATTRIBUTE
<fx:root> 'type' attributestatic String
SCRIPT_CHARSET_ATTRIBUTE
<fx:script> 'charset' attributestatic String
SCRIPT_SOURCE_ATTRIBUTE
<fx:script> 'source' attributestatic String
SCRIPT_TAG
The tag name of <fx:script>
-
Constructor Summary
Constructors Constructor Description FXMLLoader()
Creates 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 Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.BuilderFactory
getBuilderFactory()
Returns the builder factory used by this loader.Charset
getCharset()
Returns the character set used by this loader.ClassLoader
getClassLoader()
Returns the classloader used by this serializer.<T> T
getController()
Returns the controller associated with the root object.Callback<Class<?>,Object>
getControllerFactory()
Returns the controller factory used by this serializer.static ClassLoader
getDefaultClassLoader()
Returns the default class loader.LoadListener
getLoadListener()
Returns this loader's load listener.URL
getLocation()
Returns the location used to resolve relative path attribute values.ObservableMap<String,Object>
getNamespace()
Returns the namespace used by this loader.ResourceBundle
getResources()
Returns the resources used to resolve resource key attribute values.<T> T
getRoot()
Returns the root of the object hierarchy.<T> T
load()
Loads an object hierarchy from a FXML document.<T> T
load(InputStream inputStream)
Loads an object hierarchy from a FXML document.static <T> T
load(URL location)
Loads an object hierarchy from a FXML document.static <T> T
load(URL location, ResourceBundle resources)
Loads an object hierarchy from a FXML document.static <T> T
load(URL location, ResourceBundle resources, BuilderFactory builderFactory)
Loads an object hierarchy from a FXML document.static <T> T
load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory)
Loads an object hierarchy from a FXML document.static <T> T
load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory, Charset charset)
Loads an object hierarchy from a FXML document.static Class<?>
loadType(String className)
Deprecated.This method now delegates togetDefaultClassLoader()
.static Class<?>
loadType(String packageName, String className)
Deprecated.This method now delegates togetDefaultClassLoader()
.void
setBuilderFactory(BuilderFactory builderFactory)
Sets the builder factory used by this loader.void
setCharset(Charset charset)
Sets the charset used by this loader.void
setClassLoader(ClassLoader classLoader)
Sets the classloader used by this serializer and clears any existing importsvoid
setController(Object controller)
Sets the controller associated with the root object.void
setControllerFactory(Callback<Class<?>,Object> controllerFactory)
Sets the controller factory used by this serializer.static void
setDefaultClassLoader(ClassLoader defaultClassLoader)
Sets the default class loader.void
setLoadListener(LoadListener loadListener)
Sets this loader's load listener.void
setLocation(URL location)
Sets the location used to resolve relative path attribute values.void
setResources(ResourceBundle resources)
Sets the resources used to resolve resource key attribute values.void
setRoot(Object root)
Sets the root of the object hierarchy.
-
-
-
Field Detail
-
DEFAULT_CHARSET_NAME
public static final String DEFAULT_CHARSET_NAME
The character set used when character set is not explicitly specified- See Also:
- Constant Field Values
-
LANGUAGE_PROCESSING_INSTRUCTION
public static final String LANGUAGE_PROCESSING_INSTRUCTION
The tag name of language processing instruction- See Also:
- Constant Field Values
-
IMPORT_PROCESSING_INSTRUCTION
public static final String IMPORT_PROCESSING_INSTRUCTION
The tag name of import processing instruction- See Also:
- Constant Field Values
-
FX_NAMESPACE_PREFIX
public static final String FX_NAMESPACE_PREFIX
Prefix of 'fx' namespace- See Also:
- Constant Field Values
-
FX_CONTROLLER_ATTRIBUTE
public static final String FX_CONTROLLER_ATTRIBUTE
The name of fx:controller attribute of a root- See Also:
- Constant Field Values
-
FX_ID_ATTRIBUTE
public static final String FX_ID_ATTRIBUTE
The name of fx:id attribute- See Also:
- Constant Field Values
-
FX_VALUE_ATTRIBUTE
public static final String FX_VALUE_ATTRIBUTE
The name of fx:value attribute- See Also:
- Constant Field Values
-
FX_CONSTANT_ATTRIBUTE
public static final String FX_CONSTANT_ATTRIBUTE
The tag name of 'fx:constant'- Since:
- JavaFX 2.2
- See Also:
- Constant Field Values
-
FX_FACTORY_ATTRIBUTE
public static final String FX_FACTORY_ATTRIBUTE
The name of 'fx:factory' attribute- See Also:
- Constant Field Values
-
INCLUDE_TAG
public static final String INCLUDE_TAG
The tag name of <fx:include>- See Also:
- Constant Field Values
-
INCLUDE_SOURCE_ATTRIBUTE
public static final String INCLUDE_SOURCE_ATTRIBUTE
<fx:include> 'source' attribute- See Also:
- Constant Field Values
-
INCLUDE_RESOURCES_ATTRIBUTE
public static final String INCLUDE_RESOURCES_ATTRIBUTE
<fx:include> 'resources' attribute- See Also:
- Constant Field Values
-
INCLUDE_CHARSET_ATTRIBUTE
public static final String INCLUDE_CHARSET_ATTRIBUTE
<fx:include> 'charset' attribute- See Also:
- Constant Field Values
-
SCRIPT_TAG
public static final String SCRIPT_TAG
The tag name of <fx:script>- See Also:
- Constant Field Values
-
SCRIPT_SOURCE_ATTRIBUTE
public static final String SCRIPT_SOURCE_ATTRIBUTE
<fx:script> 'source' attribute- See Also:
- Constant Field Values
-
SCRIPT_CHARSET_ATTRIBUTE
public static final String SCRIPT_CHARSET_ATTRIBUTE
<fx:script> 'charset' attribute- See Also:
- Constant Field Values
-
DEFINE_TAG
public static final String DEFINE_TAG
The tag name of <fx:define>- See Also:
- Constant Field Values
-
REFERENCE_TAG
public static final String REFERENCE_TAG
The tag name of <fx:reference>- See Also:
- Constant Field Values
-
REFERENCE_SOURCE_ATTRIBUTE
public static final String REFERENCE_SOURCE_ATTRIBUTE
<fx:reference> 'source' attribute- See Also:
- Constant Field Values
-
ROOT_TAG
public static final String ROOT_TAG
The tag name of <fx:root>- Since:
- JavaFX 2.2
- See Also:
- Constant Field Values
-
ROOT_TYPE_ATTRIBUTE
public static final String ROOT_TYPE_ATTRIBUTE
<fx:root> 'type' attribute- Since:
- JavaFX 2.2
- See Also:
- Constant Field Values
-
COPY_TAG
public static final String COPY_TAG
The tag name of <fx:copy>- See Also:
- Constant Field Values
-
COPY_SOURCE_ATTRIBUTE
public static final String COPY_SOURCE_ATTRIBUTE
<fx:copy> 'source' attribute- See Also:
- Constant Field Values
-
EVENT_HANDLER_PREFIX
public static final String EVENT_HANDLER_PREFIX
The prefix of event handler attributes- See Also:
- Constant Field Values
-
EVENT_KEY
public static final String EVENT_KEY
The name of the Event object in event handler scripts- See Also:
- Constant Field Values
-
CHANGE_EVENT_HANDLER_SUFFIX
public static final String CHANGE_EVENT_HANDLER_SUFFIX
Suffix for property change/invalidation handlers- See Also:
- Constant Field Values
-
NULL_KEYWORD
public static final String NULL_KEYWORD
Value that represents 'null'- See Also:
- Constant Field Values
-
ESCAPE_PREFIX
public static final String ESCAPE_PREFIX
Escape prefix for escaping special characters inside attribute values. Serves as an escape forESCAPE_PREFIX
,RELATIVE_PATH_PREFIX
, {@link #RESOURCE_KEY_PREFIX,EXPRESSION_PREFIX
,BI_DIRECTIONAL_BINDING_PREFIX
- Since:
- JavaFX 2.1
- See Also:
- Constant Field Values
-
RELATIVE_PATH_PREFIX
public static final String RELATIVE_PATH_PREFIX
Prefix for relative location resultion- See Also:
- Constant Field Values
-
RESOURCE_KEY_PREFIX
public static final String RESOURCE_KEY_PREFIX
Prefix for resource resolution- See Also:
- Constant Field Values
-
EXPRESSION_PREFIX
public static final String EXPRESSION_PREFIX
Prefix for (variable) expression resolution- See Also:
- Constant Field Values
-
BINDING_EXPRESSION_PREFIX
public static final String BINDING_EXPRESSION_PREFIX
Prefix for binding expression resolution- See Also:
- Constant Field Values
-
BINDING_EXPRESSION_SUFFIX
public static final String BINDING_EXPRESSION_SUFFIX
Suffix for binding expression resolution- See Also:
- Constant Field Values
-
BI_DIRECTIONAL_BINDING_PREFIX
public static final String BI_DIRECTIONAL_BINDING_PREFIX
Prefix for bidirectional-binding expression resolution- Since:
- JavaFX 2.1
- See Also:
- Constant Field Values
-
BI_DIRECTIONAL_BINDING_SUFFIX
public static final String BI_DIRECTIONAL_BINDING_SUFFIX
Suffix for bidirectional-binding expression resolution- Since:
- JavaFX 2.1
- See Also:
- Constant Field Values
-
ARRAY_COMPONENT_DELIMITER
public static final String ARRAY_COMPONENT_DELIMITER
Delimiter for arrays as values- Since:
- JavaFX 2.1
- See Also:
- Constant Field Values
-
LOCATION_KEY
public static final String LOCATION_KEY
A key for location URL in namespace map- Since:
- JavaFX 2.2
- See Also:
getNamespace()
, Constant Field Values
-
RESOURCES_KEY
public static final String RESOURCES_KEY
A key for ResourceBundle in namespace map- Since:
- JavaFX 2.2
- See Also:
getNamespace()
, Constant Field Values
-
CONTROLLER_METHOD_PREFIX
public static final String CONTROLLER_METHOD_PREFIX
Prefix for controller method resolution- See Also:
- Constant Field Values
-
CONTROLLER_KEYWORD
public static final String CONTROLLER_KEYWORD
A key for controller in namespace map- Since:
- JavaFX 2.1
- See Also:
getNamespace()
, Constant Field Values
-
CONTROLLER_SUFFIX
public static final String CONTROLLER_SUFFIX
A suffix for controllers of included fxml files. The full key is stored in namespace map.- Since:
- JavaFX 2.2
- See Also:
getNamespace()
, Constant Field Values
-
INITIALIZE_METHOD_NAME
public static final String INITIALIZE_METHOD_NAME
The name of initialize method- Since:
- JavaFX 2.2
- See Also:
- Constant Field Values
-
JAVAFX_VERSION
public static final String JAVAFX_VERSION
Contains the current javafx version- Since:
- JavaFX 8.0
-
FX_NAMESPACE_VERSION
public static final String FX_NAMESPACE_VERSION
Contains the current fx namepsace version- Since:
- JavaFX 8.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FXMLLoader
public FXMLLoader()
Creates a new FXMLLoader instance.
-
FXMLLoader
public FXMLLoader(URL location)
Creates a new FXMLLoader instance.- Parameters:
location
-- Since:
- JavaFX 2.1
-
FXMLLoader
public FXMLLoader(URL location, ResourceBundle resources)
Creates a new FXMLLoader instance.- Parameters:
location
-resources
-- Since:
- JavaFX 2.1
-
FXMLLoader
public FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory)
Creates a new FXMLLoader instance.- Parameters:
location
-resources
-builderFactory
-- Since:
- JavaFX 2.1
-
FXMLLoader
public FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory)
Creates a new FXMLLoader instance.- Parameters:
location
-resources
-builderFactory
-controllerFactory
-- Since:
- JavaFX 2.1
-
FXMLLoader
public FXMLLoader(Charset charset)
Creates a new FXMLLoader instance.- Parameters:
charset
-
-
FXMLLoader
public FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory, Charset charset)
Creates a new FXMLLoader instance.- Parameters:
location
-resources
-builderFactory
-controllerFactory
-charset
-- Since:
- JavaFX 2.1
-
FXMLLoader
public FXMLLoader(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory, Charset charset, LinkedList<FXMLLoader> loaders)
Creates a new FXMLLoader instance.- Parameters:
location
-resources
-builderFactory
-controllerFactory
-charset
-loaders
-- Since:
- JavaFX 2.1
-
-
Method Detail
-
getLocation
public URL getLocation()
Returns the location used to resolve relative path attribute values.
-
setLocation
public void setLocation(URL location)
Sets the location used to resolve relative path attribute values.- Parameters:
location
-
-
getResources
public ResourceBundle getResources()
Returns the resources used to resolve resource key attribute values.
-
setResources
public void setResources(ResourceBundle resources)
Sets the resources used to resolve resource key attribute values.- Parameters:
resources
-
-
getNamespace
public ObservableMap<String,Object> getNamespace()
Returns the namespace used by this loader.
-
getRoot
public <T> T getRoot()
Returns the root of the object hierarchy.
-
setRoot
public void setRoot(Object root)
Sets 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
-
equals
public boolean equals(Object obj)
Description copied from class:Object
Indicates whether some other object is "equal to" this one.The
equals
method implements an equivalence relation on non-null object references:- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
The
equals
method for classObject
implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference valuesx
andy
, this method returnstrue
if and only ifx
andy
refer to the same object (x == y
has the valuetrue
).Note that it is generally necessary to override the
hashCode
method whenever this method is overridden, so as to maintain the general contract for thehashCode
method, which states that equal objects must have equal hash codes.- Overrides:
equals
in classObject
- Parameters:
obj
- the reference object with which to compare.- Returns:
true
if this object is the same as the obj argument;false
otherwise.- See Also:
Object.hashCode()
,HashMap
- It is reflexive: for any non-null reference value
-
getController
public <T> T getController()
Returns the controller associated with the root object.
-
setController
public void setController(Object controller)
Sets the controller associated with the root object. The value passed to this method is used as the value of the fx:controller attribute. This method must be called prior to loading the document when using controller event handlers when an fx:controller attribute is not specified in the document.- Parameters:
controller
- The controller to associate with the root object.- Since:
- JavaFX 2.2
-
getBuilderFactory
public BuilderFactory getBuilderFactory()
Returns the builder factory used by this loader.
-
setBuilderFactory
public void setBuilderFactory(BuilderFactory builderFactory)
Sets the builder factory used by this loader.- Parameters:
builderFactory
-
-
getControllerFactory
public Callback<Class<?>,Object> getControllerFactory()
Returns the controller factory used by this serializer.- Since:
- JavaFX 2.1
-
setControllerFactory
public void setControllerFactory(Callback<Class<?>,Object> controllerFactory)
Sets the controller factory used by this serializer.- Parameters:
controllerFactory
-- Since:
- JavaFX 2.1
-
getCharset
public Charset getCharset()
Returns the character set used by this loader.
-
setCharset
public void setCharset(Charset charset)
Sets the charset used by this loader.- Parameters:
charset
-- Since:
- JavaFX 2.1
-
getClassLoader
public ClassLoader getClassLoader()
Returns the classloader used by this serializer.- Since:
- JavaFX 2.1
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
Sets the classloader used by this serializer and clears any existing imports- Parameters:
classLoader
-- Since:
- JavaFX 2.1
-
getLoadListener
public LoadListener getLoadListener()
Returns this loader's load listener.- Since:
- 9
-
setLoadListener
public final void setLoadListener(LoadListener loadListener)
Sets this loader's load listener.- Since:
- 9
-
load
public <T> T load() throws IOException
Loads 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)
.- Returns:
- The loaded object hierarchy.
- Throws:
IOException
- Since:
- JavaFX 2.1
-
load
public <T> T load(InputStream inputStream) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
inputStream
- An input stream containing the FXML data to load.- Returns:
- The loaded object hierarchy.
- Throws:
IOException
-
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
-className
-- Throws:
ClassNotFoundException
-
loadType
@Deprecated public static Class<?> loadType(String className) throws ClassNotFoundException
Deprecated. This method now delegates togetDefaultClassLoader()
.Loads a type using the default class loader.- Parameters:
className
-- Throws:
ClassNotFoundException
-
getDefaultClassLoader
public static ClassLoader getDefaultClassLoader()
Returns the default class loader.- Since:
- JavaFX 2.1
-
setDefaultClassLoader
public static void setDefaultClassLoader(ClassLoader defaultClassLoader)
Sets the default class loader.- Parameters:
defaultClassLoader
- The default class loader to use when loading classes.- Since:
- JavaFX 2.1
-
load
public static <T> T load(URL location) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
location
-- Throws:
IOException
-
load
public static <T> T load(URL location, ResourceBundle resources) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
location
-resources
-- Throws:
IOException
-
load
public static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
location
-resources
-builderFactory
-- Throws:
IOException
-
load
public static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
location
-resources
-builderFactory
-controllerFactory
-- Throws:
IOException
- Since:
- JavaFX 2.1
-
load
public static <T> T load(URL location, ResourceBundle resources, BuilderFactory builderFactory, Callback<Class<?>,Object> controllerFactory, Charset charset) throws IOException
Loads an object hierarchy from a FXML document.- Parameters:
location
-resources
-builderFactory
-controllerFactory
-charset
-- Throws:
IOException
- Since:
- JavaFX 2.1
-
-