I want show an alert dialog during thread try to send a mail and I tried this code:
Alert alertPopup = new Alert(Alert.AlertType.INFORMATION);
alertPopup.setHeaderText("Sending confirmation mail!");
alertPopup.setGraphic(progressBar);
progressBar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
alertPopup.showAndWait();
MailThread MailThread = new MailThread(parameter);
Thread a = new Thread(MailThread);
a.start();
try {
a.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
Boolean status = MailThread.getResult();
if(status){
alertPopup.setContentText("Mail sent successfully");
Optional<ButtonType> result = alertPopup.showAndWait();
if(result.isPresent() && result.get() == ButtonType.OK) {
try {
onBtnBackClicked();
} catch (IOException e) {
e.printStackTrace();
}
}
}
but the alert dialog is not updated, 2 different dialog are shown