Example usage for javafx.stage Stage initOwner

List of usage examples for javafx.stage Stage initOwner

Introduction

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

Prototype

public final void initOwner(Window owner) 

Source Link

Document

Specifies the owner Window for this stage, or null for a top-level, unowned stage.

Usage

From source file:jlotoprint.MainViewController.java

public static Stage loadTemplateChooser() {
    final Stage stage = new Stage();
    try {//from www .  ja  v  a2  s. com
        FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDialog.fxml"));
        Parent root = (Parent) dialog.load();
        root.addEventHandler(TemplateDialogEvent.CANCELED, (actionEvent) -> {
            stage.close();
        });
        stage.setScene(new Scene(root));
        stage.setTitle("Choose a template");
        stage.getIcons().add(new Image("file:resources/icon.png"));
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(JLotoPrint.stage.getScene().getWindow());
        stage.show();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    return stage;
}

From source file:net.sf.anathema.framework.presenter.action.about.AnathemaAboutAction.java

private Stage initializeDialogStage(Scene scene) {
    final Stage aboutStage = new Stage();
    aboutStage.initStyle(StageStyle.UNDECORATED);
    aboutStage.initOwner(stage);
    aboutStage.setResizable(false);/*from  w  w  w.  j  a v a  2 s.c om*/
    aboutStage.setTitle(resources.getString("Help.AboutDialog.Title"));
    aboutStage.setScene(scene);
    initCloseOnEscape(aboutStage);
    return aboutStage;
}

From source file:com.esri.geoevent.clusterSimulator.ui.CertificateCheckerDialog.java

@Override
public boolean allowConnection(final X509Certificate[] chain) {
    if (trustedCerts.contains(chain[0])) {
        return true;
    }//w  w w  . j ava 2s  .  com
    final ArrayBlockingQueue<Boolean> responseQueue = new ArrayBlockingQueue<Boolean>(1);
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            try {
                final Stage dialog = new Stage();
                dialog.initModality(Modality.APPLICATION_MODAL);
                dialog.initOwner(MainApplication.primaryStage);
                dialog.setTitle("Certificate Check");
                FXMLLoader loader = new FXMLLoader(getClass().getResource("CertificateCheckerDialog.fxml"));
                Parent parent = (Parent) loader.load();
                CertCheckController controller = (CertCheckController) loader.getController();
                controller.certText.setText(chain[0].toString());
                Scene scene = new Scene(parent);
                dialog.setScene(scene);
                dialog.showAndWait();
                responseQueue.put(Boolean.valueOf(controller.allowConnection));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    };
    if (Platform.isFxApplicationThread()) {
        runnable.run();
    } else {
        Platform.runLater(runnable);
    }

    try {
        boolean retVal = responseQueue.take();
        if (retVal) {
            trustedCerts.add(chain[0]);
        }
        return retVal;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:com.coolchick.translatortemplater.Main.java

/**
 * Opens a dialog to edit details for the specified person. If the user clicks OK, the changes
 * are saved into the provided person object and true is returned.
 *
 * @param person the person object to be edited
 * @return true if the user clicked OK, false otherwise.
 *//*  ww  w  .  j  a  va 2  s  .c  o  m*/
public boolean showTranslatorEditDialog(Translator person) {
    try {
        // Load the fxml file and create a new stage for the popup dialog.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("PersonEditDialog.fxml"));
        AnchorPane page = (AnchorPane) loader.load();
        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Edit Person");
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(primaryStage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);
        // Set the person into the controller.
        PersonEditDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setMain(this);
        controller.setTranslator(person);
        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
        return controller.isOkClicked();
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}

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

public void showExportXPathToRuleWizard() throws IOException {
    ExportXPathWizardController wizard = new ExportXPathWizardController(xpathExpressionProperty());

    FXMLLoader loader = new FXMLLoader(getClass().getResource("fxml/xpath-export-wizard.fxml"));
    loader.setController(wizard);/* w w w  .  jav a 2s. c  o  m*/

    final Stage dialog = new Stage();
    dialog.initOwner(designerRoot.getMainStage());
    dialog.setOnCloseRequest(e -> wizard.shutdown());
    dialog.initModality(Modality.WINDOW_MODAL);

    Parent root = loader.load();
    Scene scene = new Scene(root);
    //stage.setTitle("PMD Rule Designer (v " + PMD.VERSION + ')');
    dialog.setScene(scene);
    dialog.show();
}

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  ww.  ja  v  a 2  s .  c om*/
        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:mesclasses.view.TimetableController.java

private Cours openEditDialog(Cours coursToEdit, Cours originalCours) {
    try {/*  w w  w.  j a va2 s . c om*/
        // Load the fxml file and create a new stage for the popup dialog.
        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("Edition d'un cours");
        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(coursToEdit, false);

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
        int status = controller.getStatus();
        if (status >= 0) {
            //update/cancel
            return controller.getCours();
        } else {
            //delete
            getPane(coursToEdit).getChildren().remove(coursToEdit.getEvent());
            int seances = model.delete(originalCours).size();
            ModalUtil.info("Sances modifies", seances + " sances ont t modifies");
            return null;
        }

    } catch (IOException e) {
        notif(e);
        return null;
    }
}

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   w w w  .j  a v  a 2 s.c o 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:io.bitsquare.app.BitsquareApp.java

private void showFPSWindow() {
    Label label = new Label();
    EventStreams.animationTicks().latestN(100).map(ticks -> {
        int n = ticks.size() - 1;
        return n * 1_000_000_000.0 / (ticks.get(n) - ticks.get(0));
    }).map(d -> String.format("FPS: %.3f", d)).feedTo(label.textProperty());

    Pane root = new StackPane();
    root.getChildren().add(label);/*from   w w  w . ja  v a  2s.c o m*/
    Stage stage = new Stage();
    stage.setScene(new Scene(root));
    stage.setTitle("FPS");
    stage.initModality(Modality.NONE);
    stage.initStyle(StageStyle.UTILITY);
    stage.initOwner(scene.getWindow());
    stage.setX(primaryStage.getX() + primaryStage.getWidth() + 10);
    stage.setY(primaryStage.getY());
    stage.setWidth(200);
    stage.setHeight(100);
    stage.show();
}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Starts the GUI for connecting to a server for a shared project.
 *///from w  ww  .j  ava  2  s . c om
public void openConnectGUI() {
    log.debug("Loading a new connect wizard.");
    ConnectWizardController connectWizard = SpringContainer.getContext().getBean(ConnectWizardController.class);

    log.trace("Creating the scene.");
    Scene scene = new Scene(connectWizard.getRootPane());
    scene.getStylesheets().add(cssPath);

    log.trace("Creating stage to display window with the scene.");
    Stage stage = new Stage();
    stage.setTitle("Remote Project Connection");
    stage.setResizable(false);
    stage.initModality(Modality.NONE);
    stage.initOwner(coreController.getStage());
    stage.setResizable(false);
    stage.setScene(scene);
    stage.show();
    log.trace("Connect wizard displayed.");
}