Example usage for javafx.stage Stage initModality

List of usage examples for javafx.stage Stage initModality

Introduction

In this page you can find the example usage for javafx.stage Stage initModality.

Prototype

public final void initModality(Modality modality) 

Source Link

Document

Specifies the modality for this stage.

Usage

From source file:jlotoprint.MainViewController.java

@FXML
public void handleOpenTemplateDesigner(ActionEvent event) {

    try {/*from   w w w .j a va 2s. c  om*/
        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);
    }
}

From source file:mesclasses.view.JourneeController.java

@FXML
public void openPostIt() {
    try {/*w w  w  .  ja  v  a  2  s.c o m*/
        // Load the fxml file and create a new stage for the popup dialog.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource(Constants.POSTIT_DIALOG));
        AnchorPane page = (AnchorPane) loader.load();

        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Post-It");
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(primaryStage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller.
        PostItDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setClasse(seanceSelect.getValue().getClasse());

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();

    } catch (IOException e) {
        LOG.error(e);
    }
}

From source file:mesclasses.view.JourneeController.java

@FXML
public void openActions() {
    try {//from   w w  w .j av  a 2 s .  co  m
        // Load the fxml file and create a new stage for the popup dialog.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource(Constants.ACTIONS_DIALOG));
        AnchorPane page = (AnchorPane) loader.load();

        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Actions  faire");
        dialogStage.initModality(Modality.NONE);
        dialogStage.initOwner(primaryStage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller.
        ActionsEnCoursController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setClasse(seanceSelect.getValue().getClasse());

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();

    } catch (IOException e) {
        LOG.error(e);
    }
}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

private void linkAccountTransac(String linkAccountTransac) {
    try {//  w  ww  .  ja  v a  2 s.  com
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(InvestiaGenOFX.class.getResource("view/linkaccountTransac.fxml"));
        AnchorPane page = (AnchorPane) loader.load();

        Stage dialogStage = new Stage();
        dialogStage.setTitle("Associer les comptes");
        dialogStage.getIcons().add(new Image("/myIcons/Teddy-Bear-Sick-icon.png"));
        dialogStage.initModality(Modality.WINDOW_MODAL);
        Scene scene = new Scene(page);
        dialogStage.initOwner(InvestiaGenOFX.getPrimaryStage());
        dialogStage.setScene(scene);
        InvestiaGenOFX.setOnCloseRequest(dialogStage);

        LinkaccountTransacController controller = loader.getController();
        controller.setlinkAccountTransac(linkAccountTransac);
        dialogStage.showAndWait();
    } catch (Exception ex) {
        Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:mesclasses.view.JourneeController.java

private Cours openCoursDialog(Cours cours) {

    try {//w ww . ja va2  s .  co m
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource(Constants.COURS_EDIT_DIALOG));
        AnchorPane page = (AnchorPane) loader.load();

        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Cration d'un cours ponctuel");
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(primaryStage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);
        // Set the person into the controller.
        CoursEditDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setCours(cours, true);

        dialogStage.showAndWait();
        int status = controller.getStatus();
        if (status >= 0) {
            //update/cancel
            return controller.getCours();
        }
    } catch (IOException e) {
        ModalUtil.alert("Erreur I/O", e.getMessage());
    }
    return null;
}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

private void showInvestmentsSummary(String accountType, Double x, Double y) {
    try {//from w  w  w  .j  a v a 2 s.c  om
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(InvestiaGenOFX.class.getResource("view/investmentsSummary.fxml"));
        AnchorPane page = (AnchorPane) loader.load();

        Stage dialogStage = new Stage();
        dialogStage.setTitle("Sommaire des Investissements " + accountType);
        dialogStage.getIcons().add(new Image("/myIcons/Teddy-Bear-Sick-icon.png"));
        dialogStage.initModality(Modality.NONE);
        Scene scene = new Scene(page);
        dialogStage.initOwner(InvestiaGenOFX.getPrimaryStage());
        dialogStage.setX(x);
        dialogStage.setY(y);
        dialogStage.setScene(scene);
        dialogStage.show();
    } catch (Exception ex) {
        Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

/**
 * Initializes the controller class./*  w  w  w.ja va2 s. 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:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

public void handleSetupLayers(Event event) {
    try {//  w  ww  . j a v a  2  s.  c om
        URL layersDialogFXML = getClass().getResource(LAYERS_DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        Stage layersDialog = loader.load();
        MsSpectrumLayersDialogController controller = loader.getController();
        controller.configure(datasets, this);
        layersDialog.initModality(Modality.APPLICATION_MODAL);
        layersDialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void initGenerateXPathFromStackTrace() {

    ContextMenu menu = new ContextMenu();

    MenuItem item = new MenuItem("Generate from stack trace...");
    item.setOnAction(e -> {/* w  ww  . jav a 2s  . co m*/
        try {
            Stage popup = new Stage();
            FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
            Parent root = loader.load();
            Button button = (Button) loader.getNamespace().get("generateButton");
            TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

            ValidationSupport validation = new ValidationSupport();

            validation.registerValidator(area,
                    Validator.createEmptyValidator("The stack trace may not be empty"));
            button.disableProperty().bind(validation.invalidProperty());

            button.setOnAction(f -> {
                DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
                popup.close();
            });

            popup.setScene(new Scene(root));
            popup.initStyle(StageStyle.UTILITY);
            popup.initModality(Modality.WINDOW_MODAL);
            popup.initOwner(designerRoot.getMainStage());
            popup.show();
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
    });

    menu.getItems().add(item);

    xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY) {
            menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY());
        }
    });
}

From source file:genrsa.GenRSAController.java

/**
 * Muestra por pantalla la informacin relativa a genRSA 
 * @param event //from w  w  w  . j a  va  2  s  .  co m
 */
public void aboutGenRSA(ActionEvent event) {
    Stage stage;
    FXMLLoader fxmlLoader;
    Parent root;

    try {
        stage = new Stage();
        fxmlLoader = new FXMLLoader(getClass().getResource("/About/About.fxml"));
        root = fxmlLoader.load();

        Scene scene = new Scene(root);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(this.unitsD.getScene().getWindow());
        stage.setResizable(false);
        stage.getIcons().add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png")));
        stage.setTitle("Acerca de genRSA v2.1");
        stage.setScene(scene);
        stage.show();

    } catch (IOException ex) {
        //no pongo mensaje de error, porque no se puede dar el caso
    }

}