Example usage for javafx.stage Stage showAndWait

List of usage examples for javafx.stage Stage showAndWait

Introduction

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

Prototype

public void showAndWait() 

Source Link

Document

Shows this stage and waits for it to be hidden (closed) before returning to the caller.

Usage

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

@Override
public void execute() {
    MigPane parent = new MigPane(new LC().fill().wrapAfter(1));
    parent.getStyleClass().add("thinborder");
    Scene scene = new Scene(parent, 300, 400);
    new Stylesheet("skin/platform/aboutDialog.css").applyToScene(scene);
    final Stage aboutStage = initializeDialogStage(scene);
    showProgramTitle(parent);/*from ww w  . j  a  v  a2s.  co m*/
    showVersion(parent);
    showCopyrightAndLicense(parent);
    showCredits(parent);
    showCloseButton(parent, aboutStage);
    aboutStage.showAndWait();
}

From source file:benedict.zhang.addon.soundmanager.controller.SoundManagerController.java

public void onSoundSelected(MouseEvent e) {
    PersistenceManager manager = PersistenceManager.getInstance();
    Sound selectItem = (Sound) (this.searchResultTableView.getSelectionModel().getSelectedItem());
    if (selectItem == null) {
        return;/* w  ww .  j  a  v  a  2s  .  c  o  m*/
    }
    Sound selectSound = manager.loadSound(selectItem.getSoundName(), selectItem.getActor());
    if (this.getMode().equals(UIViewMode.EDIT)) {
        if (e.getClickCount() >= 2) {
            try {

                SoundDataProxy.getInstance().storeSound(ApplicationUIConstants.SOUND_INFO, selectSound);
                MapChangeListener<String, Sound> listener = (
                        MapChangeListener.Change<? extends String, ? extends Sound> change) -> {
                    if (change.wasAdded()) {
                        Sound sound = SoundDataProxy.getInstance()
                                .getDataSound(ApplicationUIConstants.SOUND_INFO, Boolean.TRUE);
                        try {
                            BeanUtils.copyProperties(
                                    (Sound) (this.searchResultTableView.getSelectionModel().getSelectedItem()),
                                    sound);
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(SoundManagerController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        } catch (InvocationTargetException ex) {
                            Logger.getLogger(SoundManagerController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        }
                    }
                };
                SoundDataProxy.getInstance().addSoundConfigListener(listener);
                Stage soundManagerConfigure = SoundManagerConfigureDialog.getSoundManagerDialog(this, display,
                        UIViewMode.READONLY);
                soundManagerConfigure.showAndWait();
                SoundDataProxy.getInstance().removeSoundConfigListener(listener);
            } catch (IOException ex) {
                Logger.getLogger(SoundManagerController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    } else {
        if (e.getClickCount() >= 2) {
            SoundDataProxy.getInstance().storeSound(ApplicationUIConstants.SOUND_INFO, selectSound);
            display.hide();
        }
    }

}

From source file:account.management.controller.ViewSalaryVoucherController.java

/**
 * Initializes the controller class.//from w w w .ja  v a  2s . c om
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    this.voucher_no.setCellValueFactory(new PropertyValueFactory("id"));
    this.date.setCellValueFactory(new PropertyValueFactory("date"));
    this.section.setCellValueFactory(new PropertyValueFactory("section"));
    this.name.setCellValueFactory(new PropertyValueFactory("name"));
    this.basis.setCellValueFactory(new PropertyValueFactory("basis"));
    this.amount.setCellValueFactory(new PropertyValueFactory("total"));

    final ContextMenu contextMenu = new ContextMenu();
    MenuItem item1 = new MenuItem("    View                  ");
    item1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Data.salaryVoucher = table.getSelectionModel().getSelectedItem();

            try {
                Parent root = FXMLLoader
                        .load(getClass().getResource(MetaData.viewPath + "EditSalaryVoucher.fxml"));
                Scene scene = new Scene(root);
                Stage stage = new Stage();
                scene.setRoot(root);
                stage.setResizable(false);
                stage.setTitle("Salary Voucher");
                stage.setScene(scene);
                stage.showAndWait();
                int index = table.getSelectionModel().getSelectedIndex();
                getData();

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

        }
    });
    contextMenu.getItems().addAll(item1);
    this.table.setContextMenu(contextMenu);

}

From source file:account.management.controller.loginController.java

@FXML
private void onLoginButtonClick(ActionEvent event) {
    try {//w  ww  . ja v  a2s  .c o  m

        String username = this.username.getText();
        String password = this.password.getText();

        User.username = username;

        this.login_btn.setDisable(true);
        this.login_btn.setText("Loading...");
        Thread t = new Thread(() -> {
            try {
                HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "login")
                        .queryString("username", username).queryString("password", password).asJson();
                JSONArray array = res.getBody().getArray();
                JSONObject obj = array.getJSONObject(0);
                if (obj.getInt("inventory") == 1)
                    User.inventory = true;
                if (obj.getInt("project") == 1)
                    User.project = true;
                if (obj.getInt("lc") == 1)
                    User.lc = true;
                if (obj.getInt("cnf") == 1)
                    User.cnf = true;
                if (obj.getInt("deposit_voucher") == 1)
                    User.deposit_voucher = true;
                if (obj.getInt("expense_voucher") == 1)
                    User.expense_voucher = true;
                if (obj.getInt("sell") == 1)
                    User.sell = true;
                if (obj.getInt("purchase") == 1)
                    User.purchase = true;
                if (obj.getInt("party_create") == 1)
                    User.party_create = true;
                if (obj.getInt("ledger_create") == 1)
                    User.ledger = true;
                if (obj.getInt("voucher") == 1)
                    User.voucher = true;
                if (obj.getInt("bank") == 1)
                    User.bank = true;
                if (obj.getInt("inventory_report") == 1)
                    User.inventory_report = true;
                if (obj.getInt("trial_balance") == 1)
                    User.trial_balance = true;
                if (obj.getInt("balance_sheet") == 1)
                    User.balance_sheet = true;
                if (obj.getInt("financial_statement") == 1)
                    User.financial_statement = true;
                if (obj.getInt("database_maintanance") == 1)
                    User.database_maintanance = true;

                Platform.runLater(() -> {
                    try {
                        this.login_btn.getScene().getWindow().hide();
                        Parent root;
                        root = FXMLLoader.load(getClass().getResource(MetaData.viewPath + "home1.fxml"));
                        Scene scene = new Scene(root);
                        scene.getStylesheets().add("/style.css");
                        Stage stage = new Stage();
                        scene.setRoot(root);
                        stage.setResizable(true);
                        stage.setTitle("Home");
                        stage.setScene(scene);
                        stage.showAndWait();
                    } catch (IOException ex) {
                        Logger.getLogger(loginController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                });

            } catch (Exception ex) {
                Platform.runLater(() -> {
                    Msg.showError("Username or password is incorrect");
                });
            } finally {
                login_btn.setDisable(false);
                Platform.runLater(() -> {
                    login_btn.setText("Login");

                });

            }
        });
        t.start();

    } catch (Exception e) {
        Msg.showError("Sorry. There is an error. Please try again");
    }
}

From source file:gui.accessories.GraphPopup.java

private void initFX(JFXPanel fxPanel) {
    // This method is invoked on the JavaFX thread
    Stage window = new Stage();
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle(labels.getString("PONTOS.VITORIA"));
    window.setMinWidth(500);//from w ww .j a  v  a2s .c o  m

    Chart chart = createStackedBarChart();
    chart.setAnimated(true);
    Scene scene = new Scene(chart);

    //show and tell
    window.setScene(scene);
    window.showAndWait();

    fxPanel.setScene(scene);
}

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 av a  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:com.esri.geoevent.clusterSimulator.ui.CertificateCheckerDialog.java

@Override
public boolean allowConnection(final X509Certificate[] chain) {
    if (trustedCerts.contains(chain[0])) {
        return true;
    }/* ww  w .  j a va2s .  c  o  m*/
    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:ExcelFx.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    this.Print.setDisable(true);

    footer.setItems(names);//  w ww.j a v  a2s. c om
    JsonWrite jsw = new JsonWrite();
    File universityFile = new File("university.json");
    File collegeFile = new File("college.json");
    //File codesFile = new File("codes.json");

    if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) {
        try {
            this.universityJson.jsonRead("university.json");
            this.collegeJson.jsonRead("college.json");
            //this.codesJson.jsonRead("codes.json");
            this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
        } catch (IOException | ParseException ex) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("");
            alert.setHeaderText(" ? ? ");
            alert.setContentText(ex.toString());
            alert.showAndWait();
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml"));
            this.fileOpenParent = (Parent) fxmlLoader.load();
            Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initStyle(StageStyle.DECORATED);
            stage.setTitle(" ");
            stage.setScene(new Scene(this.fileOpenParent));

            stage.showAndWait();
        } catch (Exception e) {
            System.err.println(e);

        }

        this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
    }

}

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

private void bulkAddWords() {
    Stage stage = new Stage();
    BulkAddWordsView view = new BulkAddWordsView();
    stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST));
    stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.word_and_description")));
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initOwner(getScene().getWindow());
    stage.showAndWait();
    loadRows(view.getCards());/*from w  w w  .  j  av  a2s. c  o m*/
}

From source file:ExcelFx.FXMLDocumentController.java

@FXML
private void Open(ActionEvent event) throws NullPointerException, IOException {

    System.out.println("-----------------------------------------------------------");
    System.out.println("Pressed open Button ");
    File universityFile = new File("university.json");
    File collegeFile = new File("college.json");
    System.out.println("University File emty is " + String.valueOf(universityFile.length() == 0));
    System.out.println("College File emty is " + String.valueOf(collegeFile.length() == 0));

    //File codesFile = new File("codes.json");
    if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) {
        try {// w  w  w  .  j  av a 2  s .  com
            this.universityJson.jsonRead("university.json");
            this.collegeJson.jsonRead("college.json");
            //this.codesJson.jsonRead("codes.json");
            this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
        } catch (IOException | ParseException ex) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("");
            alert.setHeaderText(" ? ? ");
            alert.setContentText(ex.toString());
            alert.showAndWait();
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml"));
            this.fileOpenParent = (Parent) fxmlLoader.load();
            Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initStyle(StageStyle.DECORATED);
            stage.setTitle(" ");
            stage.setScene(new Scene(this.fileOpenParent));

            stage.showAndWait();
        } catch (Exception e) {
            System.err.println(e);

        }

        this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
    }

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InitalData.fxml"));
    Parent root1 = (Parent) fxmlLoader.load();
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initStyle(StageStyle.DECORATED);

    stage.setTitle(" ");
    stage.setScene(new Scene(root1));
    stage.showAndWait();
    setProgressBar(-1.);

    Task task = new Task<Void>() {

        @Override
        protected Void call() throws Exception {

            initaldata = (JsonWrite) root1.getUserData();
            System.out.println("Inital Data empty is " + initaldata.isEmpty());

            initaldata.setPage(String.valueOf(Integer.parseInt(initaldata.getPage()) - 1));

            Parser parser = new Parser();

            list = parser.parseInitalData(initaldata.getPatch(), Integer.parseInt(initaldata.getPage()));
            //System.out.println(list.size());
            Sort sort = new Sort(list, jsonXLSXData, initaldata.getYStart(), initaldata.getYEnd());
            HashMap<String, HashMap<String, ArrayList<String>>> hm = sort
                    .professionsGrouping(initaldata.getYStart(), initaldata.getYEnd());

            sortProf = sort.addWay(hm);

            return null;
        }

    };
    mainProcessing(task);

    System.out.println("button open finished");
    System.out.println("-----------------------------------------------------------");

}