@Override public Optional<ButtonType> showWarning(String title, String message) { final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); final Scene scene = alert.getDialogPane().getScene(); BrandUtil.applyBrand(injector, stage, scene); alert.setTitle("Confirmation"); alert.setHeaderText(title); alert.setContentText(message); alert.setGraphic(FontAwesome.EXCLAMATION_TRIANGLE.view()); return alert.showAndWait(); }
@Override public void start(Stage primaryStage) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("This is a Custom Confirmation Dialog"); alert.setContentText("We override the style classes of the dialog"); ... }
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); alert.showAndWait(); if (alert.getResult() == ButtonType.YES) { //do stuff }
/** * Shows a question dialog. * * @param message the message * @param defaultYes true if yes is the default button * @return true if yes, false if no */ public boolean showQuestionDialog(String message, boolean defaultYes) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(FxFxBundle.getString("QUESTION")); setAlertMessage(alert, message); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); Button noButton = (Button) alert.getDialogPane().lookupButton(ButtonType.NO); Button yesButton = (Button) alert.getDialogPane().lookupButton(ButtonType.YES); noButton.setDefaultButton(!defaultYes); yesButton.setDefaultButton(defaultYes); Optional<ButtonType> result = alert.showAndWait(); return result.isPresent() && result.get() == ButtonType.YES; }
Alert alert = new Alert(AlertType.ERROR); alert.initOwner(stage); alert.setTitle(title); alert.setHeaderText(headerText); Button reportIssueButton = new Button(Translator.translate("reportIssue")); Label label = new Label("stacktrace:"); alert.getDialogPane().setExpandableContent(expContent); ExceptionController.handleException(th, alert.getDialogPane(), reportIssueButton, textArea, alert.contentTextProperty()); alert.showAndWait();
private 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(getClass().getResourceAsStream("LICENSE"), StandardCharsets.UTF_8))); } catch (IOException e) { e.printStackTrace(); } licenseAlert.getDialogPane().setContent(scroll); licenseAlert.showAndWait(); }
webEngine.setOnAlert ( new EventHandler<WebEvent<String>>() { @Override public void handle(WebEvent<String> arg0) { Alert alert = new Alert(AlertType.INFORMATION); alert.setHeaderText("Alert"); alert.setContentText(arg0.getData()); alert.showAndWait(); } } );
private static void displayUpdateDownloadAlert() { final Alert selfupdateStartedAlert = new Alert( Alert.AlertType.CONFIRMATION, "Started downloading update in the background. We will tell you when it is ready !", ButtonType.OK ); selfupdateStartedAlert.showAndWait(); }
public static Optional<ButtonType> showSaveAndQuitDialog(String documentName) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setHeaderText(MessageFormat.format(RESOURCE_BUNDLE.getString("SaveBeforeClosing"), documentName)); alert.setContentText(RESOURCE_BUNDLE.getString("WarnSaveBeforeClosing")); ButtonType save = new ButtonType(RESOURCE_BUNDLE.getString("Save"), ButtonBar.ButtonData.YES); ButtonType dontSave = new ButtonType(RESOURCE_BUNDLE.getString("DontSave"), ButtonBar.ButtonData.NO); alert.getButtonTypes().setAll(save, dontSave, ButtonType.CANCEL); return alert.showAndWait(); }
private void showRemoveAlert() { ObservableList<TreeItem<Object>> selectedItems = contingencyTree.getSelectionModel().getSelectedItems(); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(REMOVE); if (selectedItems.size() == 1) { TreeItem<Object> item = selectedItems.get(0); if (item.getValue() instanceof Contingency) { alert.setHeaderText(REMOVE + " " + ((Contingency) item.getValue()).getId() + " ?"); } else if (item.getValue() instanceof ContingencyElement) { alert.setHeaderText(REMOVE + " " + ((ContingencyElement) item.getValue()).getId() + " ?"); } } else { alert.setHeaderText(REMOVE + " " + RESOURCE_BUNDLE.getString("SelectedElements") + " ?"); } Optional<ButtonType> result = alert.showAndWait(); result.ifPresent(type -> { if (type == ButtonType.OK) { remove(); } else { alert.close(); } }); }
public static void showDialogError(String message) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(GSE_ERROR); alert.setResizable(true); alert.setContentText(message); alert.showAndWait(); }
alert.setTitle( "Confirmation Dialog" ); alert.setHeaderText( "Look, a Confirmation Dialog" ); alert.setContentText( "Are you ok with this?" ); public void handle( ActionEvent event ) alert.setResult(ButtonType.CANCEL); alert.hide(); idlestage.play(); Optional<ButtonType> result = alert.showAndWait();
Alert dialog = new Alert(Alert.AlertType.ERROR); dialog.setHeaderText("Connection Failed"); dialog.setContentText(this.getException().getMessage()); //FIXME: Remove after release 8u40 dialog.setResizable(true); dialog.getDialogPane().setPrefSize(480, 320); dialog.showAndWait();
alertOut.setTitle("Confirmation Dialog"); alertOut.setHeaderText("Look, a Confirmation Dialog"); alertOut.setContentText("Are you ok with this?"); alertOut.initModality(Modality.NONE); ((Stage)alertOut.getDialogPane().getScene().getWindow()).setOpacity(0); buttonBar.setDisable(false); alertOut.show(); if (r1 == ButtonType.OK){ ((Stage)alertOut.getDialogPane().getScene().getWindow()).setOpacity(1); ButtonBar buttonBarOut=(ButtonBar)alertOut.getDialogPane().lookup(".button-bar"); buttonBarOut.setDisable(true); final DoubleProperty yPropertyOut = new SimpleDoubleProperty(yEnd); yPropertyOut.addListener((ov,n,n1)->alertOut.setY(n1.doubleValue())); e->alertOut.close(), new KeyValue(yPropertyOut, yIni,Interpolator.EASE_BOTH))); timeOut.play(); alertOut.close(); primaryStage.close();
/** * Shows an info dialog. * * @param message the message */ public void showInfoDialog(String message) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(FxFxBundle.getString("INFORMATION")); setAlertMessage(alert, message); alert.showAndWait(); }
@Override public void save() { try { if (documentHandler.getPath() == null) { FileChooserProvider fileChooserProvider = getFileChooserProvider(); String initialFileName = dockableData.getTitle().toLowerCase().replace(' ', '-') + "." + documentHandler.getDefaultFileExtenion(); Path documentPath = fileChooserProvider.showSaveAsDialog(initialFileName); if (documentPath != null) { documentHandler.saveNew(documentPath); configureDockableDataFromExistingDocument(dockableData, documentHandler); postSaveHandler.accept(this); } } else { documentHandler.save(); postSaveHandler.accept(this); } } catch (IOException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText(RESOURCE_BUNDLE.getString("errorAlert.contentText")); alert.showAndWait(); LOG.error("Could not write the file: " + documentHandler.getPath(), ex); } }
Alert alert = new Alert(AlertType.WARNING); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(stage); alert.getDialogPane().setContentText("Some text"); DialogPane dialogPane = alert.getDialogPane(); GridPane grid = new GridPane(); ColumnConstraints graphicColumn = new ColumnConstraints(); dialogPane.setGraphic(null); alert.showAndWait() .filter(response -> response == ButtonType.OK) .ifPresent(response -> System.out.println("The alert was approved"));
Alert alert = new Alert(AlertType.INFORMATION); alert.getDialogPane().setContent( new Text("this is a pretty long message that " + "should not be truncated in this alert window, no matter " + "how long it is")); alert.showAndWait();
// in MainApp.java public void showAlert(String myTitle, Node myContent) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(myTitle); alert.setHeaderText(null); alert.getDialogPane.setContent(myContent); alert.showAndWait(); } // or your custom stage public void showAlert(String myTitle, Node myContent) { Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setScene(new Scene(new VBox(new Label(myTitle), myContent)); dialogStage.show(); }
public void start(Stage primaryStage) throws Exception { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Title"); alert.setHeaderText("Some Text"); alert.setContentText("Choose your option."); ButtonType buttonTypeOne = new ButtonType("Yes"); ButtonType buttonTypeCancel = new ButtonType("No", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);