Android Fxml Load loadFxml(Node node)

Here you can find the source of loadFxml(Node node)

Description

Loads a fxml file and initializes a node as root and controller.

Parameter

Parameter Description
node the node

Exception

Parameter Description
IOException Signals that an I/O exception has occurred.

Declaration

public static void loadFxml(Node node) 

Method Source Code

//package com.java2s;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Node;

public class Main {
    /**/*from   w  w w.  ja va2 s . com*/
     * Loads a fxml file and initializes a node as root and controller.
     *
     * @param node
     *            the node
     * @throws IOException
     *             Signals that an I/O exception has occurred.
     */
    public static void loadFxml(Node node) {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(node.getClass()
                    .getResource(node.getClass().getSimpleName() + ".fxml"));
            fxmlLoader.setRoot(node);
            fxmlLoader.setController(node);

            fxmlLoader.load();
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        }
    }
}