Example usage for javafx.fxml FXMLLoader setLocation

List of usage examples for javafx.fxml FXMLLoader setLocation

Introduction

In this page you can find the example usage for javafx.fxml FXMLLoader setLocation.

Prototype

public void setLocation(URL location) 

Source Link

Document

Sets the location used to resolve relative path attribute values.

Usage

From source file:org.sandsoft.cymric.util.Commons.java

/**
 * Create a new custom pane from FXML data. <br>
 * Restraints: Name and package of FXML file should be the same as
 * <code>resourceClass</code>. <code>resourceClass</code> should extend
 * <code>BorderPane</code> or one of its descendents.
 *
 * @param resourceClass Pane class in which data to be loaded.
 * @return Pane type object containing loaded node.
 *//*from w  w w .  j a  v  a2 s  .  c  o m*/
public static Pane loadPaneFromFXML(Class resourceClass) throws IOException {
    //init loader           
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(resourceClass.getResource(resourceClass.getSimpleName() + ".fxml"));

    //load fxml
    Node node = (Node) loader.load();
    BorderPane control = (BorderPane) loader.getController();

    BorderPane.setAlignment(node, Pos.CENTER);
    control.setCenter(node);

    return control;
}

From source file:cz.lbenda.gui.controls.TextAreaFrmController.java

/** Create new instance return main node and controller of this node and sub-nodes */
public static Tuple2<Parent, TextAreaFrmController> createNewInstance() {
    URL resource = TextAreaFrmController.class.getResource(FXML_RESOURCE);
    try {/*from   www . j  a va  2s .  c om*/
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(resource);
        loader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent node = loader.load(resource.openStream());
        TextAreaFrmController controller = loader.getController();
        return new Tuple2<>(node, controller);
    } catch (IOException e) {
        LOG.error("Problem with reading FXML", e);
        throw new RuntimeException("Problem with reading FXML", e);
    }
}

From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java

/** Create new instance return main node and controller of this node and sub-nodes */
public static Tuple2<Parent, DbConfigFrmController> createNewInstance() {
    URL resource = DbConfigFrmController.class.getResource(FXML_RESOURCE);
    try {/*from  www  .  j a  va2  s  . co m*/
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(resource);
        loader.setBuilderFactory(new JavaFXBuilderFactory());
        Parent node = loader.load(resource.openStream());
        DbConfigFrmController controller = loader.getController();
        return new Tuple2<>(node, controller);
    } catch (IOException e) {
        LOG.error("Problem with reading FXML", e);
        throw new RuntimeException("Problem with reading FXML", e);
    }
}

From source file:org.sandsoft.acefx.AceEditor.java

/**
 * Creates a new instance of the ace editor.
 *
 * @return/*from   w w w.  j a v  a 2  s .  c  om*/
 * @throws java.io.IOException
 */
public static AceEditor createNew() throws IOException {
    //init loader           
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(AceEditor.class.getResource(AceEditor.class.getSimpleName() + ".fxml"));

    //attach node
    Node node = (Node) loader.load();
    BorderPane.setAlignment(node, Pos.CENTER);
    AceEditor ace = (AceEditor) loader.getController();
    ace.setCenter(node);
    ace.setMinSize(0, 0);
    ace.setPrefSize(600, 400);
    ace.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

    //post load work  
    ace.initialize();

    return ace;
}

From source file:br.com.ajaio.midas.desktop.MainApp.java

public void showBancoCrud() {
    try {//from  w w  w . j a v a  2s  . com
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource("view/bancoCrudFXML.fxml"));
        AnchorPane bancoCrud = (AnchorPane) loader.load();
        BancoCrudFXMLController bancoController = loader.getController();
        bancoController.setMainApp(this);

        rootLayout.setCenter(bancoCrud);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:br.com.ajaio.midas.desktop.MainApp.java

private void showLoginView() {
    try {/*from w  w w.  ja  va  2s  . c om*/
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource("view/loginFXML.fxml"));
        AnchorPane loginview = (AnchorPane) loader.load();

        LoginController controller = loader.getController();
        controller.setMainApp(this);

        rootLayout.setCenter(loginview);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:br.com.ajaio.midas.desktop.MainApp.java

public void initRootLayout() {
    try {/*  w  w  w  . java  2s .  co m*/
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource("view/rootLayoutFXML.fxml"));
        rootLayout = (BorderPane) loader.load();

        RootLayoutController rootLayoutController = loader.getController();
        rootLayoutController.setMainApp(this);

        Scene scene = new Scene(rootLayout);
        primaryStage.setScene(scene);
        primaryStage.show();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:br.com.ajaio.midas.desktop.MainApp.java

public void showDashBoardView() {
    try {//from  w  w w.j av  a  2s  .  c o m
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource("view/dashBoardFXML.fxml"));
        AnchorPane dashBoardOverview = (AnchorPane) loader.load();

        DashBoardController controller = loader.getController();
        controller.setMainApp(this);
        controller.setUsuarioLogado(usuarioLogado);
        controller.loadDashBoard();

        rootLayout.setCenter(dashBoardOverview);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ninja.eivind.hotsreplayuploader.window.nodes.BattleLobbyNode.java

public BattleLobbyNode(FXMLLoaderFactory factory) throws IOException {
    URL resource = getClass().getResource("BattleLobbyNode.fxml");
    FXMLLoader loader = factory.get();
    loader.setLocation(resource);
    loader.setRoot(this);
    loader.setController(this);
    loader.load();/*w  w w .  j  a  va2s  . co  m*/
}

From source file:dtv.DTVEdit.java

private Object load(String url) {
    FXMLLoader loader = new FXMLLoader();
    loader.setControllerFactory(clazz -> applicationContext.getBean(clazz));
    loader.setLocation(DTVEdit.class.getResource(url));

    try {/*from   w ww.  j  a v  a  2s  .c o m*/
        return loader.load();
    } catch (IOException e) {
        LOG.error("Some bad things!", e);
    }

    return null;
}