List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java
public static void showFatalException(final String title, final String message, final Throwable exception) { final Alert alert = new Alert(Alert.AlertType.ERROR); alert.initStyle(StageStyle.UTILITY); alert.setTitle("Error"); alert.setHeaderText(title);/* ww w .j av a 2s .c o m*/ alert.setContentText(message); final Label label = new Label("Details:"); final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception)); 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); final GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); }
From source file:io.github.medinam.jcheesum.util.VersionChecker.java
public static void showDownloadLatestAlert() { Alert alert = new Alert(Alert.AlertType.INFORMATION); ResourceBundle resources = ResourceBundle.getBundle("i18n/Bundle", Locale.getDefault()); alert.setTitle(resources.getString("newVersion")); alert.setHeaderText(resources.getString("newVersionLooksLike")); alert.setContentText(resources.getString("youHave") + App.class.getPackage().getImplementationVersion() + " " + resources.getString("latestVersionIs") + getLatestStable() + "\n\n" + resources.getString("wannaDownload")); ButtonType yesBtn = new ButtonType(resources.getString("yes")); ButtonType noBtn = new ButtonType(resources.getString("no"), ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(yesBtn, noBtn); Optional<ButtonType> o = alert.showAndWait(); if (o.get() == yesBtn) { General.openLink(getLatestStableDownloadURL()); } else if (o.get() == noBtn) { alert.close();/* w w w. ja va 2 s . c om*/ } }
From source file:net.thirdy.blackmarket.controls.Dialogs.java
public static void showExceptionDialog(Throwable throwable) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Sorry something wrong happened"); String header = throwable.getMessage(); header = isBlank(header) ? throwable.getClass().getSimpleName() : header; alert.setHeaderText(header);// w w w .j a v a 2 s.c o m // alert.setGraphic(new ImageView(ImageCache.getInstance().get("/images/gallio/gallio-" // + comics[RandomUtils.nextInt(0, 3)] + // ".png"))); alert.setGraphic(new ImageView(ImageCache.getInstance().get("/images/gallio/gallio-sad.png"))); // Create expandable Exception. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); String exceptionText = sw.toString(); StringBuilder sb = new StringBuilder(); // sb.append("Error Message: "); // sb.append(System.lineSeparator()); // sb.append(throwable.getMessage()); sb.append("The exception stacktrace was:"); sb.append(System.lineSeparator()); sb.append(exceptionText); TextArea textArea = new TextArea(sb.toString()); textArea.setEditable(false); textArea.setWrapText(false); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(150); // Set expandable Exception into the dialog pane. alert.getDialogPane().setExpandableContent(textArea); alert.getDialogPane().setExpanded(true); alert.showAndWait(); }
From source file:com.playonlinux.javafx.common.ErrorMessage.java
public ErrorMessage(String message, Exception exception) { LOGGER.error(ExceptionUtils.getStackTrace(exception)); alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(translate(message));/* w w w. j a va 2 s.com*/ alert.setContentText(String.format("The error was: %s", ExceptionUtils.getStackTrace(exception))); }
From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java
protected boolean showConfirmPopup(String title, String header, String contentText) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(title);/*from ww w .jav a 2 s. c o m*/ alert.setHeaderText(header); alert.setContentText(contentText); ButtonType okButton = new ButtonType("Da", ButtonBar.ButtonData.OK_DONE); ButtonType cancelButton = new ButtonType("Ne", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(okButton, cancelButton); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(uIConfig.getIcon()); Optional<ButtonType> result = alert.showAndWait(); if (result.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { return true; } return false; }
From source file:account.management.controller.createAccountTypeController.java
@FXML private void onSubmitButtonClick(ActionEvent event) { new Thread(() -> { try {/*from w w w .j av a 2 s . c o m*/ String name = this.input_account_type_name.getText(); String note = this.input_note.getText(); JSONArray response = Unirest.post(MetaData.baseUrl + "add/account_type") .queryString("type_name", name).queryString("details", note).asJson().getBody().getArray(); Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText(null); alert.setContentText("Account type has been created successfully!"); alert.setGraphic(new ImageView(new Image("resources/success.jpg"))); alert.showAndWait(); } 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(); } }).start(); }
From source file:org.blockedit.utils.ExceptionDialog.java
/** * Create a exception alert that is displayed to the user. * * @param message The message to show the user * @param title The title of the window/*from www . j av a 2s. co m*/ * @param header The message header * @param exception The exception that triggered this window to be displayed to the user * @return A created alert */ private static Alert createDialog(String message, String title, String header, Exception exception) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(message); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); String exceptionText = ExceptionUtils.getStackTrace(exception); exception.printStackTrace(); Label label = new Label("The exception stacktrace was:"); TextArea exceptionArea = new TextArea( exceptionText + "\n\n==User Information==\njava.version = " + System.getProperty("java.version") + "\nos.name = " + System.getProperty("os.name") + "\nos.arch = " + System.getProperty("os.arch") + "\nos.version = " + System.getProperty("os.version")); exceptionArea.setEditable(false); exceptionArea.setWrapText(true); exceptionArea.setMaxWidth(UserInformation.getWindowWidth() / 2); exceptionArea.setMaxHeight(UserInformation.getWindowHeight() / 2); GridPane.setVgrow(exceptionArea, Priority.ALWAYS); GridPane.setHgrow(exceptionArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(UserInformation.getWindowWidth() / 2); expContent.add(label, 0, 0); expContent.add(exceptionArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); return alert; }
From source file:org.kordamp.javatrove.example04.util.ApplicationEventHandler.java
@Handler public void handleThrowable(ThrowableEvent event) { Platform.runLater(() -> {/*from w w w .j a v a 2 s. c om*/ TitledPane pane = new TitledPane(); pane.setCollapsible(false); pane.setText("Stacktrace"); TextArea textArea = new TextArea(); textArea.setEditable(false); pane.setContent(textArea); ByteArrayOutputStream baos = new ByteArrayOutputStream(); event.getThrowable().printStackTrace(new PrintStream(baos)); textArea.setText(baos.toString()); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("An unexpected error occurred"); alert.getDialogPane().setContent(pane); alert.showAndWait(); }); }
From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java
protected void showInformationPopup(String title, String headerText, String contentText) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title);//from w w w . j ava 2 s. co m alert.setHeaderText(headerText); alert.setContentText(contentText); ButtonType okButton = new ButtonType("Nastavi", ButtonBar.ButtonData.OK_DONE); alert.getButtonTypes().setAll(okButton); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(uIConfig.getIcon()); alert.showAndWait(); }
From source file:main.TestManager.java
/** * Displays given test. Intended for testing and * evaluating correct answers. (student mode only) * @param test test to display/*from ww w . j a v a2 s . c o m*/ * @param stage */ public static void displayTest(Test test, Stage stage) { Debugger.println(test.getName() + " - is displayed."); TabPane tabPane = new TabPane(); int counter = 1; for (Question q : test.getQuestions()) { Label instruction = new Label(q.question); instruction.setStyle("-fx-font-size: 20"); Pane choices = q.getPaneOfChoices(); VBox vbox = new VBox(instruction, choices); vbox.setSpacing(10); Tab tab = new Tab("Otzka " + Integer.toString(counter), vbox); tab.setStyle("-fx-font-size: 20"); tabPane.getTabs().add(tab); counter++; } Button finish = new Button("Ukon?i test!"); finish.setStyle("-fx-font-size: 20"); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { test.evaluate(stage); } catch (IOException e) { Alert alert = new Alert(AlertType.ERROR); alert.setContentText("Ojoj, vyskytol sa problm. Aplikcia sa mus ukon?i."); alert.showAndWait(); System.exit(0); } } }); Button nextQuestion = new Button("alia"); nextQuestion.setStyle("-fx-font-size: 20"); nextQuestion.setOnAction(e -> tabPane.getSelectionModel().selectNext()); HBox buttons = new HBox(finish, nextQuestion); buttons.setSpacing(10); buttons.setAlignment(Pos.BOTTOM_CENTER); VBox outerVBox = new VBox(tabPane, buttons); outerVBox.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(outerVBox); stage.setScene(scene); stage.show(); }