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(Charset charset) 

Source Link

Document

Creates a new FXMLLoader instance.

Usage

From source file:org.sleuthkit.autopsy.imageanalyzer.FXMLConstructor.java

static public void construct(Node n, String fxmlFileName) {
    final String name = "nbres:/" + StringUtils.replace(n.getClass().getPackage().getName(), ".", "/") + "/"
            + fxmlFileName;/* w w w .j  av a  2  s  . co m*/
    //        System.out.println(name);

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(new URL(name));
        fxmlLoader.setRoot(n);
        fxmlLoader.setController(n);

        try {
            fxmlLoader.load();
        } catch (IOException exception) {
            try {
                fxmlLoader.setClassLoader(FXMLLoader.getDefaultClassLoader());
                fxmlLoader.load();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }

}

From source file:org.sleuthkit.autopsy.timeline.FXMLConstructor.java

static public void construct(Node n, String fxmlFileName) {
    final String name = "nbres:/" + StringUtils.replace(n.getClass().getPackage().getName(), ".", "/") + "/"
            + fxmlFileName; // NON-NLS
    System.out.println(name);/*ww w .  jav a  2  s .c o m*/

    try {
        FXMLLoader fxmlLoader = new FXMLLoader(new URL(name));
        fxmlLoader.setRoot(n);
        fxmlLoader.setController(n);

        try {
            fxmlLoader.load();
        } catch (IOException exception) {
            try {
                fxmlLoader.setClassLoader(FXMLLoader.getDefaultClassLoader());
                fxmlLoader.load();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:dev.archiecortez.jfacelog.dialogs.NewPassDialog.java

public NewPassDialog() throws IOException {
    super();/*from  www . ja  va 2 s.  c  om*/
    FXMLLoader loader = new FXMLLoader(getClass().getResource("newpassdialog.fxml"));
    loader.setController(this);

    Parent root = loader.load();
    this.getDialogPane().setContent(root);
    getDialogPane().getButtonTypes().add(ButtonType.APPLY);
    getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
    getDialogPane().lookupButton(ButtonType.APPLY).disableProperty()
            .bind(newPassword.textProperty().isNotEqualTo(newPasswordCopy.textProperty())
                    .or(newPassword.textProperty().isEmpty()).or(oldPassword.textProperty().isEmpty()));

    setResultConverter(value -> {
        if (value == ButtonType.APPLY) {
            return new Pair<>(oldPassword.getText(), newPassword.getText());
        } else {
            return null;
        }
    });
}

From source file:com.ggvaidya.scinames.tabulardata.TabularDataViewController.java

public static TabularDataViewController createTabularDataView() {
    Scene scene;// w  w w  . j  av a  2s  .com
    FXMLLoader loader = new FXMLLoader(
            TabularDataViewController.class.getResource("/fxml/TabularDataView.fxml"));
    AnchorPane ap;
    try {
        ap = (AnchorPane) loader.load();
    } catch (IOException e) {
        throw new RuntimeException("Could not load internal file 'TabularDataView.fxml': " + e);
    }
    scene = new Scene(ap);
    TabularDataViewController controller = loader.getController();
    controller.setScene(scene);
    return controller;
}

From source file:org.apache.cayenne.modeler.layout.LayoutSupport.java

default FXMLLoader loadFXML(final String fxmlPath) throws IOException {
    final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fxmlPath));

    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    fxmlLoader.load();// w w w .j a  va 2  s.c om

    // Note: Must manually initialize the layout because JavaFX will not
    //       automatically call the "initialize" method when the FXML is
    //       loaded from an interface's default method.  To avoid confusion
    //       with the JavaFX "initialize" name, a different method name is
    //       used for the same purpose.
    initializeLayout();

    return fxmlLoader;
}

From source file:com.toyota.carservice.config.config2.java

public Object newStage(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style,
        boolean maximized) {
    try {/*  w w  w .  j  a  va  2s.  c  o m*/
        Stage st = new Stage();
        stage = (Stage) lb.getScene().getWindow();
        FXMLLoader root = new FXMLLoader(getClass().getResource(load));

        Scene scene = new Scene(root.load());
        st.initStyle(style);
        st.setResizable(resize);
        st.setMaximized(maximized);
        st.setTitle(judul);
        st.setScene(scene);
        ApplicationContext appContex = config.getInstance().getApplicationContext();
        Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
        st.getIcons().add(new Image(resource.getURI().toString()));
        st.show();
        stage.close();
        return root.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:de.tmosebach.mm.jfxui.SpringFXMLLoader.java

public Node load(URL url) {
    try {//from www .  j a v a  2s  .  c  o m
        FXMLLoader loader = new FXMLLoader(url);
        loader.setControllerFactory(new Callback<Class<?>, Object>() {
            @Override
            public Object call(Class<?> aClass) {
                return context.getBean(aClass);
            }
        });
        return loader.load();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(String.format("Failed to load FXML file '%s'", url));
    }
}

From source file:tworpus.client.mainwindow.MainWindowController.java

@FXML
public void showOpenSession() {
    try {/*from  w w  w.j av a2  s.c om*/
        FXMLLoader loader = new FXMLLoader(openSessionFXML);
        Pane pane = (Pane) loader.load();
        maincontent = pane;
        borderPane.centerProperty().set(maincontent);

    } catch (IOException ex) {
        Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.craftercms.social.migration.MigrationTool.java

@Override
public void start(final Stage primaryStage) throws Exception {
    loadProperties();/*from   w  w w .ja  v a  2  s  . co m*/
    log.debug("Loading Fxml file");
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/scenes/Main.fxml"));
    log.debug("Fxml file Loaded, Starting scene");
    Scene scene = new Scene((VBox) loader.load());
    final MainController controller = loader.getController();
    controller.setScene(scene);
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(final WindowEvent windowEvent) {
            controller.stopTasks();
        }
    });
    primaryStage.setTitle("Crafter Social/Profile Migration Tool (2.3->2.5)");
    log.debug("Showing UI. {}", new Date());
    primaryStage.show();

}

From source file:jlotoprint.MainViewController.java

@FXML
public void handleOpenTemplateDesigner(ActionEvent event) {

    try {//from  w  w w .  jav  a 2 s.co  m
        FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDesigner.fxml"));
        Parent root = (Parent) dialog.load();
        final Stage stage = new Stage();
        stage.setOnCloseRequest((WindowEvent windowEvent) -> {
            boolean shouldClose = ((TemplateDesignerController) dialog.getController()).showSaveChangesDialog();
            //cancel event
            if (!shouldClose) {
                windowEvent.consume();
            }
        });
        root.addEventHandler(TemplateDesignerEvent.CLOSE, actionEvent -> {
            stage.close();
        });
        stage.setScene(new Scene(root));
        stage.getIcons().add(new Image("file:resources/icon.png"));
        stage.setTitle("Template Designer");
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(JLotoPrint.stage.getScene().getWindow());
        stage.show();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}