List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:pah9qdmoviereviews.MovieReviewsFXMLController.java
public void displayExceptionAlert(Exception ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Exception"); alert.setHeaderText("An Exception Occurred!"); alert.setContentText(//from w w w. j av a 2s . c om "An exception occurred. View the exception information below by clicking Show Details."); // Create expandable Exception. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); 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.helegris.szorengeteg.ui.forms.TopicFormView.java
private void bulkAddImages() { if (sortedRows.size() > 0) { Stage stage = new Stage(); BulkAddImagesView view = new BulkAddImagesView(sortedRows); stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST)); stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.image"))); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(getScene().getWindow()); stage.showAndWait();/*from www. ja va2s. c o m*/ if (view.isOk()) { view.getFiles().entrySet().stream().forEach((entry) -> { ((RowForCard) sortedRows.get(entry.getKey())).setImageFile(entry.getValue()); }); view.getImages().entrySet().stream().forEach((entry) -> { ((RowForCard) sortedRows.get(entry.getKey())).setImage(entry.getValue()); }); } } else { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(Messages.msg("alert.error")); alert.setHeaderText(Messages.msg("alert.no_words_image")); alert.setContentText(Messages.msg("alert.add_words")); alert.showAndWait(); } }
From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java
private boolean acceptDelete(File file) { String YES = bundle.getString("yes"); String NO = bundle.getString("no"); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(bundle.getString("w1DeleteISO")); alert.setHeaderText(bundle.getString("w1DeleteConfirmation").replace("%1", file.getName())); alert.setContentText(bundle.getString("deleteInfo")); ButtonType buttonYes = new ButtonType(YES, ButtonBar.ButtonData.YES); ButtonType buttonNo = new ButtonType(NO, ButtonBar.ButtonData.NO); alert.getButtonTypes().setAll(buttonNo, buttonYes); return alert.showAndWait().get().equals(buttonYes); }
From source file:statos2_0.StatOS2_0.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); GridPane root = new GridPane(); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); root.setAlignment(Pos.CENTER);//from w w w. j a v a2 s.c om root.setHgap(10); root.setVgap(10); root.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text(""); root.add(scenetitle, 0, 0, 2, 1); scenetitle.setId("welcome-text"); Label userName = new Label(":"); //userName.setId("label"); root.add(userName, 0, 1); TextField userTextField = new TextField(); root.add(userTextField, 1, 1); Label pw = new Label(":"); root.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); root.add(pwBox, 1, 2); ComboBox store = new ComboBox(); store.setItems(GetByTag()); root.add(store, 1, 3); Button btn = new Button(""); //btn.setPrefSize(100, 20); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); root.add(hbBtn, 1, 4); Button btn2 = new Button(""); //btn2.setPrefSize(100, 20); HBox hbBtn2 = new HBox(10); hbBtn2.setAlignment(Pos.BOTTOM_RIGHT); hbBtn2.getChildren().add(btn2); root.add(hbBtn2, 1, 5); final Text actiontarget = new Text(); root.add(actiontarget, 1, 6); btn2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.exit(0); } }); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (userTextField.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (pwBox.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (store.getSelectionModel().getSelectedIndex() < 0) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { try { String[] resu = checkpas(userTextField.getText(), pwBox.getText()); if (resu[0].equals("-1")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !" + "\n - "); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } else { // ... user chose CANCEL or closed the dialog } } else { // idstore = store.getSelectionModel().getSelectedIndex() + 1; updsel(idstore, Integer.parseInt(resu[0])); MainA ma = new MainA(); ma.m = (idstore); ma.MT = "m" + idstore; ma.selid = Integer.parseInt(resu[0]); ma.nameseller = resu[1]; ma.storename = store.getSelectionModel().getSelectedItem().toString(); ma.start(primaryStage); } } catch (NoSuchAlgorithmException ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); } } /** * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){ * actiontarget.setId("acttrue"); * actiontarget.setText(" !"); * MainA ma = new MainA(); * ma.m=1; * try { * ma.m=1; * ma.MT="m1"; * ma.start(primaryStage); * } catch (Exception ex) { * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex); * } * }else{ * actiontarget.setId("actfalse"); * actiontarget.setText(" !"); * } **/ } }); //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); //sSize.getHeight(); Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight()); primaryStage.setScene(scene); scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm()); primaryStage.show(); }
From source file:com.coolchick.translatortemplater.Main.java
private void showInformation(String title, String text) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title);// w w w.j a v a 2 s . c om alert.setHeaderText(null); alert.setContentText(text); alert.showAndWait(); }
From source file:utilitybasedfx.MainGUIController.java
@FXML private void eventImportCompiled(ActionEvent event) { File selectedDir = Utils.dirChooser("Please choose the project classes root folder"); File classDir = new File(Prefs.getClassPath()); boolean shouldContinue = true; if (selectedDir != null) { if (classDir.isDirectory()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("This project already exists!"); alert.setHeaderText(/*from w ww . j ava 2 s . c o m*/ "This project already has a class folder meaning it already has files imported"); alert.setContentText( "Are you sure you want to import the new source?\nPressing OK will delete the files previous imported to this project and replace them with the new files."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { classDir.delete(); } else { shouldContinue = false; } } if (shouldContinue) { shouldRefreshFileTree = true; enableWorking(new Task<String>() { @Override protected String call() throws InterruptedException { updateMessage("Copying Files..."); try { FileUtils.copyDirectory(selectedDir, classDir); } catch (IOException e) { Utils.stackErrorDialog(e); } updateMessage(""); return ""; //[FIXME] find a way to do this inline function without a class as return type } }); } } }
From source file:com.coolchick.translatortemplater.Main.java
private void showErrorDialog(Stage primaryStage, String text) { Alert dlg = new Alert(Alert.AlertType.ERROR); dlg.setTitle("NOPE.JPG"); dlg.initOwner(primaryStage);/*from w ww .j av a 2 s . c om*/ dlg.initModality(Modality.WINDOW_MODAL); dlg.getDialogPane().setContentText(text); dlg.show(); }
From source file:eu.over9000.skadi.ui.MainWindow.java
private void setupToolbar(final Stage stage) { this.add = GlyphsDude.createIconButton(FontAwesomeIcons.PLUS); this.addName = new TextField(); this.addName.setOnAction(event -> this.add.fire()); this.add.setOnAction(event -> { final String name = this.addName.getText().trim(); if (name.isEmpty()) { return; }// www. j a va2 s . c o m final boolean result = this.channelHandler.addChannel(name, this.sb); if (result) { this.addName.clear(); } }); this.imprt = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD); this.imprt.setOnAction(event -> { final TextInputDialog dialog = new TextInputDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); dialog.setTitle("Import followed channels"); dialog.setHeaderText("Import followed channels from Twitch"); dialog.setGraphic(null); dialog.setContentText("Twitch username:"); dialog.showAndWait().ifPresent(name -> { final ImportFollowedService ifs = new ImportFollowedService(this.channelHandler, name, this.sb); ifs.start(); }); }); this.details = GlyphsDude.createIconButton(FontAwesomeIcons.INFO); this.details.setDisable(true); this.details.setOnAction(event -> { this.detailChannel.set(this.table.getSelectionModel().getSelectedItem()); if (!this.sp.getItems().contains(this.detailPane)) { this.sp.getItems().add(this.detailPane); this.doDetailSlide(true); } }); this.details.setTooltip(new Tooltip("Show channel information")); this.remove = GlyphsDude.createIconButton(FontAwesomeIcons.TRASH); this.remove.setDisable(true); this.remove.setOnAction(event -> { final Channel candidate = this.table.getSelectionModel().getSelectedItem(); final Alert alert = new Alert(AlertType.CONFIRMATION); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(stage); alert.setTitle("Delete channel"); alert.setHeaderText("Delete " + candidate.getName()); alert.setContentText("Do you really want to delete " + candidate.getName() + "?"); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { this.channelHandler.getChannels().remove(candidate); this.sb.setText("Removed channel " + candidate.getName()); } }); this.refresh = GlyphsDude.createIconButton(FontAwesomeIcons.REFRESH); this.refresh.setTooltip(new Tooltip("Refresh all channels")); this.refresh.setOnAction(event -> { this.refresh.setDisable(true); final ForcedChannelUpdateService service = new ForcedChannelUpdateService(this.channelHandler, this.sb, this.refresh); service.start(); }); this.settings = GlyphsDude.createIconButton(FontAwesomeIcons.COG); this.settings.setTooltip(new Tooltip("Settings")); this.settings.setOnAction(event -> { final SettingsDialog dialog = new SettingsDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); final Optional<StateContainer> result = dialog.showAndWait(); if (result.isPresent()) { this.persistenceHandler.saveState(result.get()); } }); this.onlineOnly = new ToggleButton("Live", GlyphsDude.createIcon(FontAwesomeIcons.FILTER)); this.onlineOnly.setSelected(this.currentState.isOnlineFilterActive()); this.onlineOnly.setOnAction(event -> { this.currentState.setOnlineFilterActive(this.onlineOnly.isSelected()); this.persistenceHandler.saveState(this.currentState); this.updateFilterPredicate(); }); // TODO re-enable if 8u60 is released this.onlineOnly.setDisable(true); this.filterText = new TextField(); this.filterText.textProperty().addListener((obs, oldV, newV) -> this.updateFilterPredicate()); this.filterText.setTooltip(new Tooltip("Filter channels by name, status and game")); // TODO re-enable if 8u60 is released this.filterText.setDisable(true); this.tb = new ToolBar(); this.tb.getItems().addAll(this.addName, this.add, this.imprt, new Separator(), this.refresh, this.settings, new Separator(), this.onlineOnly, this.filterText, new Separator(), this.details, this.remove); this.chatAndStreamButton = new HandlerControlButton(this.chatHandler, this.streamHandler, this.table, this.tb, this.sb); this.updateFilterPredicate(); }
From source file:com.mycompany.songbitmaven.RecommendationController.java
@FXML public void about(ActionEvent e) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("About"); alert.setHeaderText("Song Recommender Information"); alert.setContentText(// w w w . j a va 2s .c om "Product Completed June 4th, 2016" + "\n" + "by Alex Gajweski, Ashwin Aggarwal, and Luis de Pablo"); alert.showAndWait(); }
From source file:pah9qdmoviereviews.MovieReviewsFXMLController.java
private void displayAboutAlert() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("About"); alert.setHeaderText("New York Times Moview Review Viewer"); alert.setContentText(//w ww.j a va 2 s .c o m "An application for searching and viewing movie reviews from the New York Times. Developed by Pearse Hutson."); alert.showAndWait(); }