Example usage for javafx.fxml FXMLLoader getRoot

List of usage examples for javafx.fxml FXMLLoader getRoot

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public <T> T getRoot() 

Source Link

Document

Returns the root of the object hierarchy.

Usage

From source file:com.github.tddts.jet.view.fx.spring.DialogProvider.java

private <T extends Dialog<?>> T getDialogWithContent(FxDialog dialogAnnotation) {
    FXMLLoader loader = loadDialogView(dialogAnnotation);
    T dialog = loader.getController();// w ww  . j  av a 2 s.  c o m
    setDialogContent(dialog, loader.getRoot(), dialogAnnotation);
    return dialog;
}

From source file:com.properned.application.SystemController.java

@FXML
public void openHelpDialog() {
    logger.info("Open the help dialog");
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/helpFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {//from   ww w.  ja v a  2 s.c  o  m
        loader.load();
        Parent root = loader.getRoot();
        Stage modalDialog = new Stage();
        modalDialog.setTitle(MessageReader.getInstance().getMessage("menu.help.help"));
        modalDialog.setResizable(true);
        modalDialog.getIcons().add(new Image("/com/properned/style/icon/icon_16.png"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");
        modalDialog.setScene(scene);
        modalDialog.show();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:com.properned.application.SystemController.java

@FXML
public void openAboutDialog() {
    logger.info("Open the about dialog");
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/aboutFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {/*w  w w .  j a v a 2 s  .  com*/
        loader.load();

        Parent root = loader.getRoot();

        Stage modalDialog = new Stage(StageStyle.UTILITY);
        modalDialog.initOwner(Properned.getInstance().getPrimaryStage());
        modalDialog.setTitle(MessageReader.getInstance().getMessage("menu.help.about"));
        modalDialog.setResizable(false);

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");

        modalDialog.setScene(scene);

        modalDialog.showAndWait();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:com.properned.application.SystemController.java

@FXML
public void openLocaleDialog() {
    logger.info("Open the locale dialog");

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/localeFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {/*from   www  . j  a va  2  s  . co m*/
        loader.load();

        Parent root = loader.getRoot();

        Stage modalDialog = new Stage(StageStyle.UNIFIED);
        modalDialog.initModality(Modality.APPLICATION_MODAL);
        modalDialog.initOwner(Properned.getInstance().getPrimaryStage());
        modalDialog.setTitle(MessageReader.getInstance().getMessage("manageLocale.title"));
        modalDialog.setResizable(true);
        modalDialog.getIcons().add(new Image("/com/properned/style/icon/icon_16.png"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");

        modalDialog.setScene(scene);

        modalDialog.showAndWait();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onProgenesisImport(ActionEvent event) {
    try {/*from ww w.  j av  a 2  s .  c  om*/
        FXMLLoader loader = new FXMLLoader(getClass().getResource("progenesis/importer.fxml"));
        loader.load();
        Parent root = loader.getRoot();
        Stage stage = new Stage();
        stage.setScene(new Scene(root));

        ProgenesisImporterController controller = loader.getController();
        controller.setMainWindowController(this);
        controller.setStage(stage);
        stage.setTitle("Import data from Progenesis CSV and Sample Info Excel");
        stage.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onProgenesisCreateTemplate(ActionEvent event) {
    try {//from   ww  w.  j  av a  2  s. co  m
        FXMLLoader loader = new FXMLLoader(getClass().getResource("progenesis/createtemplate.fxml"));
        loader.load();
        Parent root = loader.getRoot();
        Stage stage = new Stage();
        stage.setScene(new Scene(root));

        TemplateCreatorController controller = loader.getController();
        controller.setMainWindowController(this);
        controller.setStage(stage);
        stage.setTitle("Create Sample Info Template from Progenesis Output");
        stage.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onOpen(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Metabolome Analysis File");
    fileChooser.getExtensionFilters()/*w  w w. j  a  va 2 s  . com*/
            .addAll(new FileChooser.ExtensionFilter("Supported Files", Arrays.asList("*.zip", "*.csv")));
    File file = fileChooser.showOpenDialog(stage);
    if (file == null)
        return;
    if (!opened) {
        openData(file);
    } else {
        try {
            Stage primaryStage = new Stage();
            FXMLLoader loader = new FXMLLoader(getClass().getResource("mainwindow.fxml"));
            loader.load();
            MainWindowController controller = loader.getController();
            controller.setStage(primaryStage);
            VBox root = loader.getRoot();
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);
            controller.openData(file);
            primaryStage.show();
        } catch (IOException e) {
            e.printStackTrace();
            AlertHelper.showExceptionAlert("Cannot open", null, e);
        }
    }
}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

/**
 * Initializes the controller class.//from ww  w  .j  a  va 2s.  c  o m
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    ScriptingEngine.setLoginManager(new IGitHubLoginManager() {

        @Override
        public String[] prompt(String username) {
            if (!loginWindowOpen && controller != null)
                controller.reset();
            loginWindowOpen = true;
            System.err.println("Calling login from BowlerStudio");
            // new RuntimeException().printStackTrace();
            FXMLLoader fxmlLoader = BowlerStudioResourceFactory.getGithubLogin();
            Parent root = fxmlLoader.getRoot();
            if (controller == null) {
                controller = fxmlLoader.getController();
                Platform.runLater(() -> {
                    controller.reset();
                    controller.getUsername().setText(username);
                    Stage stage = new Stage();
                    stage.setTitle("GitHub Login");
                    stage.initModality(Modality.APPLICATION_MODAL);
                    controller.setStage(stage, root);
                    stage.centerOnScreen();
                    stage.show();
                });
            }
            // setContent(root);
            while (!controller.isDone()) {
                ThreadUtil.wait(100);
            }
            String[] creds = controller.getCreds();
            loginWindowOpen = false;
            return creds;
        }
    });

    jfx3dmanager = new BowlerStudio3dEngine();

    setApplication(new BowlerStudioController(jfx3dmanager, this));
    Platform.runLater(() -> {
        editorContainer.getChildren().add(getApplication());
        AnchorPane.setTopAnchor(getApplication(), 0.0);
        AnchorPane.setRightAnchor(getApplication(), 0.0);
        AnchorPane.setLeftAnchor(getApplication(), 0.0);
        AnchorPane.setBottomAnchor(getApplication(), 0.0);

        subScene = jfx3dmanager.getSubScene();
        subScene.setFocusTraversable(false);
        subScene.setOnMouseEntered(mouseEvent -> {
            // System.err.println("3d window requesting focus");
            Scene topScene = BowlerStudio.getScene();
            normalKeyPessHandle = topScene.getOnKeyPressed();
            jfx3dmanager.handleKeyboard(topScene);
        });

        subScene.setOnMouseExited(mouseEvent -> {
            // System.err.println("3d window dropping focus");
            Scene topScene = BowlerStudio.getScene();
            topScene.setOnKeyPressed(normalKeyPessHandle);
        });

        subScene.widthProperty().bind(viewContainer.widthProperty());
        subScene.heightProperty().bind(viewContainer.heightProperty());
    });

    Platform.runLater(() -> {
        jfx3dControls.getChildren().add(jfx3dmanager.getControlsBox());
        viewContainer.getChildren().add(subScene);
    });

    System.out.println("Welcome to BowlerStudio!");
    new Thread() {
        public void run() {
            setName("Load Haar Thread");
            try {
                HaarFactory.getStream(null);
            } catch (Exception ex) {
            }
        }
    }.start();

    // getAddDefaultRightArm().setOnAction(event -> {
    //
    // application.onAddDefaultRightArm(event);
    // });
    // getAddVRCamera().setOnAction(event -> {
    // if(AddVRCamera.isSelected())
    // application.onAddVRCamera(event);
    // });

    FxTimer.runLater(Duration.ofMillis(100), () -> {
        if (ScriptingEngine.getLoginID() != null) {
            setToLoggedIn(ScriptingEngine.getLoginID());
        } else {
            setToLoggedOut();
        }

    });

    ScriptingEngine.addIGithubLoginListener(new IGithubLoginListener() {

        @Override
        public void onLogout(String oldUsername) {
            setToLoggedOut();
        }

        @Override
        public void onLogin(String newUsername) {
            setToLoggedIn(newUsername);

        }
    });

    cmdLine = new CommandLineWidget();

    Platform.runLater(() -> {
        // logView.resize(250, 300);
        // after connection manager set up, add scripting widget
        logViewRef = new TextArea();
        logViewRef.prefWidthProperty().bind(logView.widthProperty().divide(2));
        logViewRef.prefHeightProperty().bind(logView.heightProperty().subtract(40));
        VBox box = new VBox();
        box.getChildren().add(logViewRef);
        box.getChildren().add(cmdLine);
        VBox.setVgrow(logViewRef, Priority.ALWAYS);
        box.prefWidthProperty().bind(logView.widthProperty().subtract(10));

        logView.getChildren().addAll(box);
    });
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void showUmodel(final String obj, final String file) {
    Platform.runLater(() -> {/*w  ww .jav a2s  .c om*/
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("smview/smview.fxml"));
            loader.load();
            SMView controller = loader.getController();
            controller.setStaticmesh(getStaticMeshDir(), file, obj);
            Scene scene = new Scene(loader.getRoot());
            scene.setOnKeyReleased(controller::onKeyReleased);

            Stage smStage = new Stage();
            smStage.setScene(scene);
            smStage.setTitle(obj);
            smStage.show();

            smStage.setX(Double.parseDouble(L2smr.getPrefs().get("smview.x", String.valueOf(smStage.getX()))));
            smStage.setY(Double.parseDouble(L2smr.getPrefs().get("smview.y", String.valueOf(smStage.getY()))));
            smStage.setWidth(Double
                    .parseDouble(L2smr.getPrefs().get("smview.width", String.valueOf(smStage.getWidth()))));
            smStage.setHeight(Double
                    .parseDouble(L2smr.getPrefs().get("smview.height", String.valueOf(smStage.getHeight()))));

            InvalidationListener listener = observable -> {
                L2smr.getPrefs().put("smview.x", String.valueOf(Math.round(smStage.getX())));
                L2smr.getPrefs().put("smview.y", String.valueOf(Math.round(smStage.getY())));
                L2smr.getPrefs().put("smview.width", String.valueOf(Math.round(smStage.getWidth())));
                L2smr.getPrefs().put("smview.height", String.valueOf(Math.round(smStage.getHeight())));
            };
            smStage.xProperty().addListener(listener);
            smStage.yProperty().addListener(listener);
            smStage.widthProperty().addListener(listener);
            smStage.heightProperty().addListener(listener);
        } catch (IOException e) {
            onException("Couldn't show staticmesh", e);
        }
    });
}