Module javafx.fxml
Package javafx.fxml

Class FXMLLoader



  • public class FXMLLoader
    extends Object
    Loads an object hierarchy from an XML document.
    Since:
    JavaFX 2.0
    • 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
    • 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 -
      • 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 return true.
        • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
        • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
        • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
        • For any non-null reference value x, x.equals(null) should return false.

        The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

        Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

        Overrides:
        equals in class Object
        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
      • 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 to setLocation(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
      • 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