Java Code Examples for javafx.scene.control.Alert#showAndWait()
The following examples show how to use
javafx.scene.control.Alert#showAndWait() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginUIController.java From RentLio with Apache License 2.0 | 8 votes |
@FXML private void adminLoginAction(){ String userName = txtAdminUserName.getText(); String password = txtAdminPassword.getText(); if (!userName.isEmpty() && !password.isEmpty()){ for (AdminDTO adminDTO: adminDTOList ) { if (adminDTO.getAdminName().equals(userName) && adminDTO.getPassword().equals(password)){ loadDashBoardUI(); }else { Alert adminLoginFailedAlert = new Alert(Alert.AlertType.ERROR); DialogPane dialogPane = adminLoginFailedAlert.getDialogPane(); dialogPane .getStylesheets().add(getClass() .getResource("/css/dialog-pane-styles.css") .toExternalForm()); dialogPane.getStyleClass().add("myDialog"); adminLoginFailedAlert.setTitle("Admin Login"); adminLoginFailedAlert.setHeaderText("Admin Login failed"); adminLoginFailedAlert.setContentText("Please check your user name or password again."); adminLoginFailedAlert.showAndWait(); } } } }
Example 2
Source File: GameElimniationController.java From MyBox with Apache License 2.0 | 6 votes |
protected void promptDeadlock() { try { FxmlControl.BenWu2(); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(getBaseTitle()); alert.setContentText(AppVariables.message("NoValidElimination")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); ButtonType buttonRenew = new ButtonType(AppVariables.message("RenewGame")); ButtonType buttonChance = new ButtonType(AppVariables.message("MakeChance")); alert.getButtonTypes().setAll(buttonRenew, buttonChance); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonRenew) { newGame(false); popInformation(message("DeadlockDetectRenew")); } else if (result.get() == buttonChance) { makeChance(); popInformation(message("DeadlockDetectChance")); } } catch (Exception e) { logger.debug(e.toString()); } }
Example 3
Source File: Edition.java From PDF4Teachers with Apache License 2.0 | 6 votes |
public static void clearEdit(File file, boolean confirm){ if(confirm){ Alert alert = Builders.getAlert(Alert.AlertType.CONFIRMATION, TR.tr("Confirmation")); alert.setHeaderText(TR.tr("Êtes vous sûr de vouloir supprimer l'édition de ce document ?")); alert.setContentText(TR.tr("Cette action est irréversible.")); Optional<ButtonType> result = alert.showAndWait(); if(result.isEmpty()) return; if(result.get() == ButtonType.OK){ confirm = false; } } if(!confirm){ if(MainWindow.mainScreen.getStatus() == MainScreen.Status.OPEN){ if(MainWindow.mainScreen.document.getFile().getAbsolutePath().equals(file.getAbsolutePath())){ MainWindow.mainScreen.document.edition.clearEdit(false); return; } } Edition.getEditFile(file).delete(); MainWindow.lbFilesTab.files.refresh(); } }
Example 4
Source File: Resumen.java From uip-pc2 with MIT License | 6 votes |
public void transferir(ActionEvent actionEvent) { Stage stage = (Stage) movimientos.getScene().getWindow(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Transferencia.fxml")); Parent root = null; try { root = fxmlLoader.load(); } catch (Exception e) { Alert alerta = new Alert(Alert.AlertType.ERROR); alerta.setTitle("Error de Aplicación"); alerta.setContentText("Llama al lapecillo de sistemas."); alerta.showAndWait(); Platform.exit(); } FadeTransition ft = new FadeTransition(Duration.millis(1500), root); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); Transferencia controller = fxmlLoader.<Transferencia>getController(); controller.cargar_datos(cuenta.getText()); // ¯\_(ツ)_/¯ cuenta viene de la linea 27 Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
Example 5
Source File: ListViewHelperMainController.java From examples-javafx-repos1 with Apache License 2.0 | 6 votes |
@FXML public void showEmployeesHelper(ActionEvent evt) { Button btn = (Button)evt.getSource(); Point2D point = btn.localToScreen(0.0d + btn.getWidth(), 0.0d - btn.getHeight()); try { Popup employeesHelper = new ListViewHelperEmployeesPopup(tfEmployee, point); employeesHelper.show(btn.getScene().getWindow()); } catch(Exception exc) { exc.printStackTrace(); Alert alert = new Alert(AlertType.ERROR, "Error creating employees popup; exiting"); alert.showAndWait(); btn.getScene().getWindow().hide(); // close and implicit exit } }
Example 6
Source File: TakeOrderController.java From Online-Food-Ordering-System with MIT License | 5 votes |
public static void infoBox1(String infoMessage, String headerText, String title){ Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(headerText); alert.setContentText(infoMessage); alert.showAndWait(); }
Example 7
Source File: OptionsPathDialogController.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@FXML private void doChooser(final ActionEvent actionEvent) { DirectoryChooser directoryChooser = new DirectoryChooser(); String modelDirectory = model.directoryProperty().getValue(); if (!modelDirectory.isBlank()) { directoryChooser.setInitialDirectory(new File(model.directoryProperty().getValue())); } File dir = directoryChooser.showDialog(optionsPathDialogScene.getWindow()); if (dir != null) { if (dir.listFiles().length > 0) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Directory Not Empty"); alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n" + "All ini files in this directory may be overwritten. " + "Are you sure?"); Optional<ButtonType> buttonType = alert.showAndWait(); buttonType.ifPresent(option -> { if (option != ButtonType.YES) { return; } }); } model.directoryProperty().setValue(dir.getAbsolutePath()); } }
Example 8
Source File: MainController.java From Schillsaver with MIT License | 5 votes |
/** Deletes all jobs selected within the view's job list. */ private void deleteSelectedJobs() { // Prompt the user to confirm their choice. final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confirm Deletion"); alert.setHeaderText("Are you sure you want to delete the job(s)?"); alert.setContentText(""); alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO); final Optional<ButtonType> alertResult = alert.showAndWait(); if (! alertResult.isPresent() || alertResult.get() == ButtonType.NO) { return; } // Delete jobs if user confirmed choice. final MainModel model = (MainModel) super.getModel(); final MainView view = (MainView) super.getView(); final ListView<String> jobsList = view.getJobsList(); final List<String> selectedJobs = FXCollections.observableArrayList(jobsList.getSelectionModel().getSelectedItems()); for (final String jobName : selectedJobs) { view.getJobsList().getItems().remove(jobName); model.getJobs().remove(jobName); } jobsList.getSelectionModel().clearSelection(); updateButtonStates(); }
Example 9
Source File: AdminPanelController.java From Online-Food-Ordering-System with MIT License | 5 votes |
public static void infoBox(String infoMessage, String headerText, String title){ Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setContentText(infoMessage); alert.setTitle(title); alert.setHeaderText(headerText); alert.showAndWait(); }
Example 10
Source File: ExceptionDetailsErrorDialog.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private static void doOpenError(final Node node, final String title, final String message, final Exception exception) { final Alert dialog = new Alert(AlertType.ERROR); dialog.setTitle(title); dialog.setHeaderText(message); if (exception != null) { // Show the simple exception name, // e.g. "Exception" or "FileAlreadyExistsException" without package name, // followed by message dialog.setContentText(exception.getClass().getSimpleName() + ": " + exception.getMessage()); // Show exception stack trace in expandable section of dialog final ByteArrayOutputStream buf = new ByteArrayOutputStream(); exception.printStackTrace(new PrintStream(buf)); // User can copy trace out of read-only text area final TextArea trace = new TextArea(buf.toString()); trace.setEditable(false); dialog.getDialogPane().setExpandableContent(trace); } dialog.setResizable(true); dialog.getDialogPane().setPrefWidth(800); if (node != null) DialogHelper.positionDialog(dialog, node, -400, -200); dialog.showAndWait(); }
Example 11
Source File: ValidationController.java From School-Management-System with Apache License 2.0 | 5 votes |
public boolean validateDate(TextField txt) { if (txt.getText().matches("\\d{4}-\\d{2}-\\d{2}")) { return true; } else { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Student Registration"); alert.setHeaderText(null); alert.setContentText("Invalid Date..!"); alert.showAndWait(); return false; } }
Example 12
Source File: DisplayNavigationViewController.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** * Try to open resource, show error dialog on failure * * @param file Resource to open * @param stage Stage to use to prompt for specific app. * Otherwise <code>null</code> to use default app. */ private void openResource(final File file, final Stage stage) { if (!ApplicationLauncherService.openFile(file, stage != null, stage)) { final Alert alert = new Alert(AlertType.ERROR); alert.setHeaderText("Failed to open file: " + file); DialogHelper.positionDialog(alert, treeView, -300, -200); alert.showAndWait(); } }
Example 13
Source File: ProjectorArenaPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
private void showPerspectiveUsageMessage() { if (config.showedPerspectiveMessage() || config.inDebugMode()) return; final Alert recalibrationAlert = new Alert(AlertType.INFORMATION); final String message = "Did you know that ShootOFF supports configuring targets to appear at real " + "world distances? ShootOFF supports this feature out of the box for some cameras, but " + "with your camera you need to recalibrate the arena with the perspective " + "calibration pattern.\n\nPlease print out this file and tape it to your wall or " + "projector screen in view of the camera pointed at your projection:\n\n" + System.getProperty("shootoff.home") + File.separator + "targets" + File.separator + "PerspectiveCalibrationPattern.pdf\n\nThen hit Projector -> Start Calibrating.\n\n" + "This message will only show once, so take notes for future reference!"; recalibrationAlert.setTitle("Real World Distances"); recalibrationAlert.setHeaderText("Add the Paper Pattern and Use Real World Target Distances!"); recalibrationAlert.setResizable(true); recalibrationAlert.setContentText(message); if (shootOffStage != null) recalibrationAlert.initOwner(shootOffStage); recalibrationAlert.showAndWait(); config.setShowedPerspectiveMessage(true); try { config.writeConfigurationFile(); } catch (ConfigurationException | IOException e) { logger.error("Failed to persist showed perspective manager settings.", e); } }
Example 14
Source File: Main.java From Image-Cipher with Apache License 2.0 | 5 votes |
private static boolean displayNotification() { logger.info("New version is available. Displaying update alert"); Alert alert = new Alert(AlertType.INFORMATION); alert.setHeaderText("New update is available to download"); alert.showAndWait(); return true; }
Example 15
Source File: SimplePopups.java From pmd-designer with BSD 2-Clause "Simplified" License | 5 votes |
public static void showLicensePopup() { Alert licenseAlert = new Alert(AlertType.INFORMATION); licenseAlert.setWidth(500); licenseAlert.setHeaderText("License"); ScrollPane scroll = new ScrollPane(); try { scroll.setContent(new TextArea(IOUtils.toString(SimplePopups.class.getResourceAsStream(LICENSE_FILE_PATH), StandardCharsets.UTF_8))); } catch (IOException e) { e.printStackTrace(); } licenseAlert.getDialogPane().setContent(scroll); licenseAlert.showAndWait(); }
Example 16
Source File: AlertBuilder.java From RentLio with Apache License 2.0 | 5 votes |
private void infoAlert(){ Alert adminLoginFailedAlert = new Alert(Alert.AlertType.INFORMATION); DialogPane dialogPane = adminLoginFailedAlert.getDialogPane(); dialogPane.getStylesheets().add( getClass().getResource("/css/dialog-pane-styles.css") .toExternalForm()); dialogPane.getStyleClass().add("myDialog"); adminLoginFailedAlert.setTitle(title); adminLoginFailedAlert.setHeaderText(headerText); adminLoginFailedAlert.setContentText(contentText); adminLoginFailedAlert.showAndWait(); }
Example 17
Source File: MZmineGUI.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public static void requestQuit() { Alert alert = new Alert(AlertType.CONFIRMATION); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(mzMineIcon); alert.setTitle("Confirmation"); alert.setHeaderText("Exit MZmine"); String s = "Are you sure you want to exit?"; alert.setContentText(s); Optional<ButtonType> result = alert.showAndWait(); if ((result.isPresent()) && (result.get() == ButtonType.OK)) { Platform.exit(); System.exit(0); } }
Example 18
Source File: ControllerMaster.java From dctb-utfpr-2018-1 with Apache License 2.0 | 4 votes |
public void displayInformationAlert(String message) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setContentText(message); alert.showAndWait(); }
Example 19
Source File: PdfAttributesController.java From MyBox with Apache License 2.0 | 4 votes |
@FXML @Override public void saveAction() { if (sourceFile == null) { return; } if ((userPasswordInput.getText() != null && !userPasswordInput.getText().isEmpty()) || (ownerPasswordInput.getText() != null && !ownerPasswordInput.getText().isEmpty())) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(myStage.getTitle()); alert.setContentText(AppVariables.message("SureSetPassword")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); ButtonType buttonSure = new ButtonType(AppVariables.message("Sure")); ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel")); alert.getButtonTypes().setAll(buttonSure, buttonCancel); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != buttonSure) { return; } } final PdfInformation modify = new PdfInformation(sourceFile); modify.setAuthor(authorInput.getText()); modify.setTitle(titleInput.getText()); modify.setSubject(subjectInput.getText()); modify.setCreator(creatorInput.getText()); modify.setProducer(producerInput.getText()); modify.setKeywords(keywordInput.getText()); if (modifyTime != null) { modify.setModifyTime(modifyTime.getTime()); } if (createTime != null) { modify.setCreateTime(createTime.getTime()); } if (version > 0) { modify.setVersion(version); } modify.setUserPassword(userPasswordInput.getText()); modify.setOwnerPassword(ownerPasswordInput.getText()); AccessPermission acc = AccessPermission.getOwnerAccessPermission(); acc.setCanAssembleDocument(assembleCheck.isSelected()); acc.setCanExtractContent(extractCheck.isSelected()); acc.setCanExtractForAccessibility(extractCheck.isSelected()); acc.setCanFillInForm(fillCheck.isSelected()); acc.setCanModify(modifyCheck.isSelected()); acc.setCanModifyAnnotations(modifyCheck.isSelected()); acc.setCanPrint(printCheck.isSelected()); acc.setCanPrintDegraded(printCheck.isSelected()); modify.setAccess(acc); synchronized (this) { if (task != null) { return; } task = new SingletonTask<Void>() { private boolean pop; @Override protected boolean handle() { return PdfTools.setAttributes(sourceFile, pdfInfo.getOwnerPassword(), modify); } @Override protected void whenSucceeded() { loadPdfInformation(ownerPasswordInput.getText()); popSuccessful(); } }; openHandlingStage(task, Modality.WINDOW_MODAL); Thread thread = new Thread(task); thread.setDaemon(true); thread.start(); } }
Example 20
Source File: SettingsDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@FXML public void save(ActionEvent evt) { boolean roundUp = rbRoundUp.isSelected(); settingsDAO.setRoundUp( roundUp ); try { settingsDAO.save(); } catch(IOException exc) { String msg = "Error saving settings to '" + settingsDAO.getAbsolutePath() + "'"; logger.error( msg, exc ); Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.showAndWait(); } close(evt); }