Example usage for javafx.scene.control Alert Alert

List of usage examples for javafx.scene.control Alert Alert

Introduction

In this page you can find the example usage for javafx.scene.control Alert Alert.

Prototype

public Alert(@NamedArg("alertType") AlertType alertType) 

Source Link

Document

Creates an alert with the given AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

Usage

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @return liste des fichiers/*from   ww w . j  av  a 2 s  . co  m*/
 */
private File[] choixFichiers() {
    File[] fileLstFich = null;
    FileChooser fcRepertChoix = new FileChooser();
    fcRepertChoix.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("fichier Image (*.jpg|*.bmp|*.tif)", "*.jpg", "*.bmp", "*.tif"));
    File fileRepert = new File(strRepertFichier + File.separator);
    fcRepertChoix.setInitialDirectory(fileRepert);
    List<File> fileListe = fcRepertChoix.showOpenMultipleDialog(stTransformations);
    int i = 0;
    boolean bAttention = false;
    if (fileListe != null) {
        File[] fileLstFich1 = new File[fileListe.size()];
        for (File fileLst : fileListe) {
            if (i == 0) {
                strRepertFichier = fileLst.getParent();
            }
            String strNomFich = fileLst.getAbsolutePath();
            String strExtension;
            strExtension = strNomFich.substring(strNomFich.lastIndexOf(".") + 1, strNomFich.length())
                    .toLowerCase();
            Image img = null;
            if (!strExtension.equals("tif")) {
                img = new Image("file:" + strNomFich);
            } else {
                try {
                    img = ReadWriteImage.readTiff(strNomFich);
                } catch (ImageReadException | IOException ex) {
                    Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) {
                if (img.getWidth() == 2 * img.getHeight()) {
                    fileLstFich1[i] = fileLst;
                    i++;
                } else {
                    bAttention = true;
                }
            } else {
                if (img.getWidth() == img.getHeight()) {
                    String strNom = fileLst.getAbsolutePath().substring(0,
                            fileLst.getAbsolutePath().length() - 6);
                    boolean bTrouve = false;
                    for (int j = 0; j < i; j++) {
                        String strNom1 = fileLstFich1[j].getAbsolutePath().substring(0,
                                fileLst.getAbsolutePath().length() - 6);
                        if (strNom.equals(strNom1)) {
                            bTrouve = true;
                        }
                    }
                    if (!bTrouve) {
                        fileLstFich1[i] = fileLst;
                        i++;
                    }
                } else {
                    bAttention = true;
                }

            }
        }
        if (bAttention) {
            Alert alert = new Alert(AlertType.ERROR);
            alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
            alert.setHeaderText(null);
            alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType"));
            alert.showAndWait();
        }
        fileLstFich = new File[i];
        System.arraycopy(fileLstFich1, 0, fileLstFich, 0, i);
        lblDragDropE2C.setVisible(false);
    }

    return fileLstFich;
}

From source file:frontend.GUIController.java

@FXML
void showAbout(ActionEvent event) {
    /*Dialogs.create()/*from   w  w w  .j  a v a  2s  . co m*/
    .title("About")
    .message(getLicense())
    .showInformation();*/
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.initOwner(stage);
    alert.initModality(Modality.APPLICATION_MODAL);
    alert.setTitle("SAIL 1.1: About");
    alert.setHeaderText("SAIL 1.1 details");
    alert.setContentText("SAIL 1.1");
    Label label = new Label("SAIL License details:");

    TextArea textArea = new TextArea(getLicense());
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();

}

From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java

/**
 *
 * @param file The location of the file downloaded from the google sheet.
 * @return The dates the scheduled traffic.
 *///from   w ww  . j  a v a  2s .  com
//    private ArrayList<LocalDate> parseDates(File file) {
//        BufferedReader TSVFile = null;
//        ArrayList<LocalDate> answer = new ArrayList<>(7);
//        try {
//            TSVFile = new BufferedReader(new FileReader(file.getAbsoluteFile()));
//            String dataRow = TSVFile.readLine();
//            while (dataRow != null) {
//                String[] row = dataRow.split("\t");
//                System.out.println("I think the day is " + row[0]);
//                answer.add(LocalDate.parse("20" + row[0]));
//                dataRow = TSVFile.readLine();
//            }
//            TSVFile.close();
////            return answer;
//        } catch (FileNotFoundException ex) {
//            Logger.getLogger(Main2Controller.class.getName()).log(Level.SEVERE, null, ex);
//        } catch (IOException ex) {
//            Logger.getLogger(Main2Controller.class.getName()).log(Level.SEVERE, null, ex);
//        } finally {
//            try {
//                TSVFile.close();
//            } catch (IOException ex) {
//                Logger.getLogger(Main2Controller.class.getName()).log(Level.SEVERE, null, ex);
//            }
//
//        }
//        return answer;
//    }
private void handleFileWriting() {
    //ArrayList<String> filenames = new ArrayList<>(dates.size());

    dates.parallelStream().forEach(x -> {
        int index = dates.indexOf(x);

        if (!dateChecks[index].isSelected()) {
            return;
        }

        //Am i already imported?
        File alreadyThereFile = isPresentForDate(x);
        if (null != alreadyThereFile) {
            UI(() -> {
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                alert.setTitle("Re-import?");
                alert.setContentText("Hey there, just thought I'd let you know "
                        + "that you've already imported a file for this day: "
                        + x.format(DateTimeFormatter.ISO_DATE) + ". Because I found this file: "
                        + alreadyThereFile.getName() + "\nAre you sure you want to do this?");
                Optional<ButtonType> answer = alert.showAndWait();
                if (answer.isPresent() && answer.get().getButtonData().equals(ButtonData.OK_DONE)) {
                    writeFile(toWideOrbitTitle(x), data.get(index));
                    UI(() -> {
                        datePickers[index].setStyle("-fx-background-color: yellow");
                        dayLabels[index].setStyle("-fx-background-color: yellow");
                    });
                    synchronized (lock) {
                        myfiles.add(toWideOrbitTitle(x));
                        System.out.println("Adding: " + toWideOrbitTitle(x));
                        System.out.println(myfiles.toString());

                    }
                } else {
                    log("Skipping: " + alreadyThereFile.getName());
                }
            });
        } else {
            writeFile(toWideOrbitTitle(x), data.get(index));
            UI(() -> {
                datePickers[index].setStyle("-fx-background-color: yellow");
                dayLabels[index].setStyle("-fx-background-color: yellow");
            });
            synchronized (lock) {
                myfiles.add(toWideOrbitTitle(x));
            }
        }
    });
}

From source file:org.cirdles.ambapo.userInterface.AmbapoUIController.java

@FXML
private void convertFromLeftLatLongToRightLatLongButtonClicked(MouseEvent event) {
    try {//w ww .j  a v a 2 s.c o m
        Coordinate result = LatLongToLatLong.convert(new BigDecimal(fromLatitude.getText()),
                new BigDecimal(fromLongitude.getText()), datumChooserLatLongFrom.getValue(),
                datumChooserLatLongTo.getValue());

        toLatitude.setText(result.getLatitude().toString());
        toLongitude.setText(result.getLongitude().toString());

        toLatitude.setDisable(false);
        toLongitude.setDisable(false);

    } catch (Exception ex) {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Error");
        alert.setHeaderText("Unable to complete conversion.");
        alert.setContentText("Check if you have valid coordinates.");
        alert.showAndWait();
        Logger.getLogger(AmbapoUIController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

@FXML
private void onSubmitButtonClick(ActionEvent event) {
    //        if(new Date().getTime() > 1471365130021l){
    //            System.exit(0);
    //        }// w w  w .j a v a  2s.c  o m

    try {
        String loc, project_id = "0", date, narration;
        JSONObject transaction;
        loc = String.valueOf(this.select_location.getSelectionModel().getSelectedItem().getId());
        if (this.select_type.getSelectionModel().isEmpty()) {
            project_id = "0";
        } else {
            project_id = this.select_type.getSelectionModel().getSelectedItem().getId();

        }
        date = new SimpleDateFormat("yyyy-MM-dd").format(
                new SimpleDateFormat("yyyy-MM-dd").parse(this.input_date.getValue().toString())) + " 00:00:00";
        narration = this.input_narration.getText();

        transaction = new JSONObject();
        JSONArray transactionArray = new JSONArray();
        JSONArray transaction_print = new JSONArray();
        for (int i = 0; i < this.field_container.getChildren().size(); i++) {
            HBox row = (HBox) this.field_container.getChildren().get(i);
            JSONObject inner = new JSONObject();
            JSONObject transaction_obj_print = new JSONObject();
            ComboBox<Account> acc = (ComboBox<Account>) row.getChildren().get(0);
            TextField dr = (TextField) row.getChildren().get(1);
            TextField cr = (TextField) row.getChildren().get(2);
            TextField remarks = (TextField) row.getChildren().get(3);
            int acc_id;
            float amount;
            String remark;
            acc_id = acc.getSelectionModel().getSelectedItem().getId();
            if (!dr.getText().equals("")) {
                amount = Float.parseFloat(dr.getText());
            } else {
                amount = Float.parseFloat(cr.getText());
                amount *= -1;
            }
            transaction_obj_print.put("account_id", acc.getSelectionModel().getSelectedItem().getId());
            transaction_obj_print.put("dr", dr.getText().isEmpty() ? "" : dr.getText());
            transaction_obj_print.put("cr", cr.getText().isEmpty() ? "" : cr.getText());
            transaction_obj_print.put("remark", remarks.getText().isEmpty() ? "" : remarks.getText());
            transaction_print.put(transaction_obj_print);
            remark = remarks.getText();

            inner.put("amount", String.valueOf(amount));
            inner.put("account_id", String.valueOf(acc_id));
            inner.put("remark", narration);
            transactionArray.put(inner);
        }

        transaction.put("transaction", transactionArray);
        System.out.println(transaction);
        HttpResponse<JsonNode> res = null;
        try {
            res = Unirest.post(MetaData.baseUrl + "add/voucher").field("location_id", loc)
                    .field("voucher_type",
                            this.select_voucher_type.getSelectionModel().getSelectedItem().getId())
                    .field("projectOrCnf", project_id).field("date", date).field("narration", narration)
                    .field("transaction", transaction).asJson();

            JSONObject obj = res.getBody().getArray().getJSONObject(0);
            if (obj.getString("Status").equals("Success")) {
                Msg.showInformation("Voucher has been saved successfully!!!");
                JSONObject obj2 = new JSONObject();
                obj2.put("transactions", transaction_print);
                JSONArray transaction_array_print = new JSONArray();
                transaction_array_print.put(obj2);
                String voucher_id = Unirest.get(MetaData.baseUrl + "get/lastVoucherId").asString().getBody();
                gerReport(voucher_id,
                        new SimpleDateFormat("dd-MM-yyyy")
                                .format(new SimpleDateFormat("yyyy-MM-dd").parse(date)),
                        narration, this.select_voucher_type.getSelectionModel().getSelectedItem().getName(),
                        this.select_location.getSelectionModel().getSelectedItem().getName(),
                        transaction_array_print.toString());

            } else {
                Msg.showError("Sorry. Something is wrong. Please try again.");
            }

        } catch (UnirestException ex) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setHeaderText(null);
            alert.setContentText("Sorry!! there is an error in the server. Please try again.");
            alert.setGraphic(new ImageView(new Image("resources/error.jpg")));
            alert.showAndWait();
        } finally {
            System.out.println(res.getBody());

        }

    } catch (Exception ex) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText(null);
        alert.setContentText("Sorry!! there is an error. Please try again.");
        alert.setGraphic(new ImageView(new Image("resources/error.jpg")));
        alert.showAndWait();
    }

}

From source file:org.cirdles.ambapo.userInterface.AmbapoUIController.java

@FXML
private void convertFromRightLatLongToLeftLatLongButtonClicked(MouseEvent event) {
    try {/*from  w ww. jav a2 s.  c om*/
        Coordinate result = LatLongToLatLong.convert(new BigDecimal(toLatitude.getText()),
                new BigDecimal(toLongitude.getText()), datumChooserLatLongTo.getValue(),
                datumChooserLatLongFrom.getValue());

        fromLatitude.setText(result.getLatitude().toString());
        fromLongitude.setText(result.getLongitude().toString());

    } catch (Exception ex) {
        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Error");
        alert.setHeaderText("Unable to complete conversion.");
        alert.setContentText("Check if you have valid coordinates.");
        alert.showAndWait();
        Logger.getLogger(AmbapoUIController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:statos2_0.MainA.java

public void finishnal(String ttitg, String ress, int selt) {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("");
    alert.setHeaderText("");
    alert.setContentText("  ");
    ButtonType buttonCheck = new ButtonType(" ");
    ButtonType buttonTOK = new ButtonType("");
    ButtonType buttonCancel2 = new ButtonType("", ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(buttonCheck, buttonTOK, buttonCancel2);
    Optional<ButtonType> result3 = alert.showAndWait();
    if (result3.get() == buttonCheck) {
        printerstart(ttitg, ress);/*  www  .j a  v a2s  . com*/
        finishnal(ttitg, ress, selt);
    } else if (result3.get() == buttonTOK) {
        //jsares
        for (int i = 0; i < jsares.size(); i++) {
            if (jsares.get(i).has("seltype")) {

            } else {
                jsares.get(i).put("seltype", selt);
                jsares.get(i).put("idcheck", checkcheck());
                jsares.get(i).put("dolgid", 0);
            }
        }

        sendJson(jsares);
        if (selt == 1) {
            double titgr = Double.parseDouble(titg.getText());
            addkas(titgr, 0, titgr, 0);
        } else if (selt == 2) {
            double titgr = Double.parseDouble(titg.getText());
            addkas(0, titgr, 0, titgr);
        }
        jsares.clear();
        int chknum = checkcheck();
        chknum++;
        chup(chknum);
        itog = 0;
        res.setText("");
        titg.setText("");
        sp3.setVisible(false);
        lb3.setVisible(false);
        t3.setVisible(false);
        bt3.setVisible(false);
        sp1.setVisible(false);
        lb1.setVisible(false);
        t1.setVisible(false);
        lbb1.setVisible(false);
        spb1.setVisible(false);
        bt1.setVisible(false);
        cbx4.setVisible(false);
        sp2.setVisible(false);
        lb2.setVisible(false);
        t2.setVisible(false);
        bt2.setVisible(false);
        cbx1.getSelectionModel().clearSelection();
        cbx2.getSelectionModel().clearSelection();
        cbx3.getSelectionModel().clearSelection();
        cbx4.getSelectionModel().clearSelection();
        sp1.getValueFactory().setValue(0.0);
        sp2.getValueFactory().setValue(0);
        sp3.getValueFactory().setValue(0);
        spb1.getValueFactory().setValue(0);
        //

    } else if (result3.get() == buttonCancel2) {

    }
}

From source file:ui.main.MainViewController.java

private void sendImage() {
    if (!contactsManager.getAvailabilityforSharing(currentChat.getParticipant())) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user is not available!");
        alert.setContentText("The file receiving user should be available online to receive the file.");
        alert.showAndWait();/* w  w  w  .j av a  2s .  c  om*/
        return;
    }
    ItemType type = contactsManager.getUserType(currentChat.getParticipant());
    if (type.equals(ItemType.none)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The is not available for you!");
        alert.setContentText(
                "The user has not accepted the Friend Request." + " The user is not available for you.");
        alert.showAndWait();
        return;
    } else if (type.equals(ItemType.from)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user has not accepted!");
        alert.setContentText("The user has not accepted the Friend Request."
                + " You can not send any messages until the user accepts the friend request.");
        alert.showAndWait();
        return;
    } else if (type.equals(ItemType.to)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user has not accepted!");
        alert.setContentText("The user has not accepted the Friend Request."
                + " You can not send any messages until the user accepts the friend request.");
        alert.showAndWait();
        return;
    }
    try {
        FileChooser fc = new FileChooser();
        fc.setTitle("Choose an image to send");
        fc.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("All Images", "*.jpg*", "*.png", "*.bmp"),
                new FileChooser.ExtensionFilter("JPG", "*.jpg"),
                new FileChooser.ExtensionFilter("PNG", "*.png"),
                new FileChooser.ExtensionFilter("BMP", "*.bmp"));

        File file = fc.showOpenDialog(presence.getScene().getWindow());
        if (file == null) {
            return;
        }
        BufferedImage image = ImageIO.read(file);
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    fileManager.sendFile(file, currentChat.getParticipant());
                    if (history.isSelected()) {
                        Timestamp time = new Timestamp(System.currentTimeMillis());
                        DBSingleChat.savePictureMessage(currentChat.getParticipant(), false, file.getPath(),
                                time);
                    }

                    paintSentPhoto(currentChat, file, dtfT.print(DateTime.now()));

                    Task tt = new Task() {
                        @Override
                        protected Object call() throws Exception {
                            Thread.sleep(500);
                            return new Object();
                        }
                    };

                    tt.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax()));

                    Thread thread1 = new Thread(tt);
                    thread1.start();
                } catch (FileNotFoundException ex) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("IMP");
                    alert.setHeaderText("File is not Found!");
                    alert.setContentText("File you selected does not exist.");
                    alert.showAndWait();
                    return;
                }
            }
        });
        t.start();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:utilitybasedfx.MainGUIController.java

private void enableWorking(Task task) {
    btnImportSource.setDisable(true);/*  ww w.j a va2 s. c  o  m*/
    btnImportCompiled.setDisable(true);
    btnCompileFromSource.setDisable(true);
    btnGenerate.setDisable(true);

    lblWorking.setVisible(true);
    barWorking.setVisible(true);
    lblWorkingTask.setVisible(true);

    lblWorkingTask.textProperty().bind(task.messageProperty());
    barWorking.progressProperty().bind(task.progressProperty());

    task.stateProperty().addListener(new ChangeListener<Worker.State>() {
        @Override
        public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State oldState,
                Worker.State newState) {
            if (newState == Worker.State.SUCCEEDED) {
                disableWorking();
            } else if (newState == Worker.State.FAILED) {
                disableWorking();

                //Utils.stackErrorDialog((Exception)task.getException());
                task.getException().printStackTrace();

                Alert alert = new Alert(AlertType.ERROR);
                alert.setTitle("There was an error");
                alert.setHeaderText("There was some kind of error while trying to do the current task");
                alert.setContentText(task.getException().toString());

                alert.showAndWait();
            }
        }
    });

    new Thread(task).start();
}

From source file:com.cdd.bao.editor.EditSchema.java

private boolean confirmClose() {
    pullDetail();//from   w  w w  .  j  a  v  a2  s.c  o  m

    if (!stack.isDirty())
        return true;

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Close Window");
    alert.setHeaderText("Abandon changes");
    alert.setContentText("Closing this window will cause modifications to be lost.");

    Optional<ButtonType> result = alert.showAndWait();
    return result.get() == ButtonType.OK;
}