Example usage for javafx.fxml FXMLLoader FXMLLoader

List of usage examples for javafx.fxml FXMLLoader FXMLLoader

Introduction

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

Prototype

public FXMLLoader() 

Source Link

Document

Creates a new FXMLLoader instance.

Usage

From source file:ninja.eivind.hotsreplayuploader.di.HotSReplayUploaderConfiguration.java

@Bean
public FXMLLoaderFactory fxmlLoader(ControllerFactory controllerFactory, BuilderFactory builderFactory) {
    return () -> {
        FXMLLoader loader = new FXMLLoader();
        loader.setControllerFactory(controllerFactory);
        loader.setBuilderFactory(builderFactory);
        return loader;
    };/* w w w . j  a  va 2 s.  c  om*/
}

From source file:at.ac.tuwien.qse.sepm.gui.App.java

@Override
public void start(Stage stage) throws Exception {
    logger.info("Application started.");

    FXMLLoader loader = new FXMLLoader();
    loader.setControllerFactory(context::getBean);

    // set base location so that resources can be loaded using relative paths
    loader.setLocation(getClass().getClassLoader().getResource("view"));

    Parent root = loader.load(getClass().getClassLoader().getResourceAsStream("view/Main.fxml"));

    stage.setScene(new Scene(root));

    stage.setTitle("travelimg");
    stage.getIcons().add(getApplicationIcon());
    stage.show();// w  ww. j a va2 s . c  o m

    PhotoService photoService = (PhotoService) context.getBean("photoService");
    photoService.initializeRepository();
}

From source file:ninja.javafx.smartcsv.fx.FXMLController.java

protected final void loadFXML() throws IOException {
    try (InputStream fxmlStream = getClass().getResourceAsStream(fxmlFilePath)) {
        FXMLLoader loader = new FXMLLoader();
        loader.setResources(ResourceBundle.getBundle(this.resourcePath));
        loader.setController(this);
        this.view = (loader.load(fxmlStream));
    } catch (Throwable t) {
        t.printStackTrace();/*  w w w .jav  a2 s  .c o m*/
    }
}

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

private void showLoginView() {
    try {//from   www .ja va 2  s.  c o m
        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:main.Content.java

public void initTabRootLayout(Activity totalSum) {
    try {/*from w  w  w.  j a v a 2 s .com*/
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("view/TabRoot.fxml"));
        tabRootLayout = (TabPane) loader.load();

        tabRootLayout.setStyle(Main.class.getResource("view/DarkTheme.css").toString());

        chartTabController.setData(data);
        chartTabController.setTabPane(tabRootLayout);
        chartTabController.setMainApp(this);
        chartTabController.setActivitySum(totalSum);
        chartTabController.showChartOverview();
        tabRootLayout = chartTabController.getTabPane();

        rootLayout.setCenter(tabRootLayout);

    } catch (IOException e) {
        e.printStackTrace();
    }
}

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

/**
 * Creates a new instance of the ace editor.
 *
 * @return//from   w ww .  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:net.noctuasource.noctua.core.ui.ExceptionDialog.java

protected ExceptionDialog(Exception exception) {
    this.exception = exception;

    VBox root = new VBox();

    stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setTitle("Exception");
    Scene scene = new Scene(root);
    scene.getStylesheets().add(getClass().getResource(CSS_FILE).toExternalForm());
    stage.setScene(scene);/*  w  w w .  j ava 2 s.  c  o  m*/

    FXMLLoader loader = new FXMLLoader();
    loader.setClassLoader(getClass().getClassLoader());
    loader.setController(this);
    loader.setLocation(getClass().getResource(FXML_FILE));

    try {
        Node node = (Node) loader.load();
        root.getChildren().add(node);
        VBox.setVgrow(node, Priority.ALWAYS);
    } catch (IOException e) {
        logger.error("Error while creating view: ", e);
        stage.close();
        return;
    }

    messageField.setText(exception.getLocalizedMessage());
    fullExceptionField.setText(ExceptionUtils.getFullStackTrace(exception));

    //stage.sizeToScene();
    stage.centerOnScreen();
    stage.show();
}

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

public void showDashBoardView() {
    try {/*from w  ww  .  j  ava 2  s  .  co 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:retsys.client.controller.LoginController.java

private Initializable replaceSceneContent(String fxml) throws Exception {

    URL location = getClass().getResource(fxml);
    FXMLLoader fxmlLoader = new FXMLLoader();

    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
    InputStream in = getClass().getResourceAsStream(fxml);
    Parent root;//from  ww  w  .ja v a  2 s.c  om

    fxmlLoader.setLocation(location);
    AnchorPane page;
    try {
        page = (AnchorPane) fxmlLoader.load(in);
    } finally {
        in.close();
    }

    Scene scene = new Scene(page);
    scene.getStylesheets().add(this.getClass().getResource("/retsys/client/css/styles.css").toExternalForm());
    stage.setScene(scene);
    stage.setFullScreen(true);
    //stage.sizeToScene();

    return (Initializable) fxmlLoader.getController();
}

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 {//w  w w  . j  ava 2 s  . c  o  m
        return loader.load();
    } catch (IOException e) {
        LOG.error("Some bad things!", e);
    }

    return null;
}