List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:se.trixon.filebydate.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);//from w w w . ja va 2s.c om alert.setTitle(Dict.OPTIONS.toString()); alert.setGraphic(null); alert.setHeaderText(null); Label label = new Label(Dict.CALENDAR_LANGUAGE.toString()); LocaleComboBox localeComboBox = new LocaleComboBox(); CheckBox checkBox = new CheckBox(Dict.DYNAMIC_WORD_WRAP.toString()); GridPane gridPane = new GridPane(); //gridPane.setGridLinesVisible(true); gridPane.addColumn(0, label, localeComboBox, checkBox); GridPane.setMargin(checkBox, new Insets(16, 0, 0, 0)); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(gridPane); localeComboBox.setLocale(mOptions.getLocale()); checkBox.setSelected(mOptions.isWordWrap()); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { mOptions.setLocale(localeComboBox.getLocale()); mOptions.setWordWrap(checkBox.isSelected()); } }
From source file:account.management.controller.inventory.InsertStockController.java
@FXML private void onSaveButtonClick(ActionEvent event) { this.save.setDisable(true); try {/*from ww w. jav a 2 s .c om*/ String date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.date.getValue().toString())); JSONArray array = new JSONArray(); for (int i = 0; i < this.conatiner.getChildren().size(); i++) { HBox row = (HBox) this.conatiner.getChildren().get(i); ComboBox<Product> item = (ComboBox) row.getChildren().get(0); TextField qty = (TextField) row.getChildren().get(1); TextField rate = (TextField) row.getChildren().get(2); JSONObject obj = new JSONObject(); obj.put("id", item.getSelectionModel().getSelectedItem().getId()); obj.put("quantity", qty.getText()); obj.put("rate", rate.getText()); array.put(obj); } Unirest.post(MetaData.baseUrl + "products/ledger") .field("voucher_type", this.voucher_type.getSelectionModel().getSelectedItem()) .field("date", date).field("products", array).asString(); Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText(null); alert.setContentText("Ledger has been saved successfully!"); alert.setGraphic(new ImageView(new Image("resources/success.jpg"))); alert.showAndWait(); this.save.setDisable(false); } catch (Exception ex) { Logger.getLogger(InsertStockController.class.getName()).log(Level.SEVERE, null, 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(); } }
From source file:de.pixida.logtest.designer.MainWindow.java
private void createAndAppendHelpMenuItems(final Menu help) { final MenuItem visitDocumentation = new MenuItem("Visit Online Documentation"); visitDocumentation.setGraphic(Icons.getIconGraphics("help")); visitDocumentation.setOnAction(event -> { Exception ex = null;/*from w ww . j ava 2s.c om*/ final String url = "https://github.com/Pixida/logtest/wiki"; final Desktop desktop = java.awt.Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { try { desktop.browse(new URI(url)); } catch (final Exception e) { ex = e; } } else { ex = new Exception("Browsing not supported."); } if (ex != null) { ExceptionDialog.showFatalException("Failed to open browser", "Visit us at " + url, ex); } }); final MenuItem about = new MenuItem("About " + APP_TITLE); about.setGraphic(Icons.getIconGraphics(APP_ICON)); about.setOnAction(event -> { final Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.initStyle(StageStyle.UTILITY); alert.setTitle(about.getText()); alert.setHeaderText(APP_TITLE); alert.setContentText("Copyright (C) " + Calendar.getInstance().get(Calendar.YEAR) + " Pixida GmbH\n" + "\n" + "This application includes FAMFAMFAM icons (http://www.famfamfam.com)."); alert.showAndWait(); }); help.getItems().addAll(visitDocumentation, about); }
From source file:org.cryptomator.ui.InitializeController.java
private boolean shouldEncryptExistingFiles() { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(localization.getString("initialize.alert.directoryIsNotEmpty.title")); alert.setHeaderText(null);/*ww w .j av a2 s . c om*/ alert.setContentText(localization.getString("initialize.alert.directoryIsNotEmpty.content")); final Optional<ButtonType> result = alert.showAndWait(); return ButtonType.OK.equals(result.get()); }
From source file:be.makercafe.apps.makerbench.Main.java
private ContextMenu createViewerContextMenu() { ContextMenu rootContextMenu = new ContextMenu(); // Add Folder.. MenuItem addFolder = new MenuItem("Add folder.."); addFolder.setOnAction(new EventHandler<ActionEvent>() { @Override//from w w w.jav a2 s .c o m public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfolder"); dialog.setTitle("New folder"); dialog.setHeaderText("Create a new folder"); dialog.setContentText("Folder name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { if (!file.mkdir()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating folder"); alert.setContentText("Folder path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); // Delete folder MenuItem deleteFolder = new MenuItem("Delete folder.."); deleteFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete folder"); alert.setContentText("Please confirm deleteion of selected folder and all it's contents ?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { try { FileUtils.deleteDirectory(file); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting folder"); alert.setContentText("Error messsage: " + e.getMessage()); alert.showAndWait(); } } } } }); // Add File.. MenuItem addFile = new MenuItem("Add file.."); addFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfile.txt"); dialog.setTitle("New file"); dialog.setHeaderText("Create a new file (.jfxscad, .jfxmill, .txt, .md, .xml, .gcode"); dialog.setContentText("File name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { try { file.createNewFile(); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating file"); alert.setContentText( "File path: " + file.getAbsolutePath() + "\nError message: " + e.getMessage()); alert.showAndWait(); } } } } }); // Delete file MenuItem deleteFile = new MenuItem("Delete file.."); deleteFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete file"); alert.setContentText("Please confirm deleteion of selected file"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { if (!file.delete()) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting file"); alert.setContentText("File path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); rootContextMenu.getItems().addAll(addFolder, deleteFolder, addFile, deleteFile); return rootContextMenu; }
From source file:ExcelFx.FXMLDocumentController.java
private void mainProcessing(Task task) { final Thread thread = new Thread(null, task, "Background"); thread.setDaemon(true);/*from w w w . j ava2 s .c om*/ thread.start(); new Thread() { @Override public void run() { try { thread.join(); } catch (InterruptedException e) { } Platform.runLater(() -> { setProgressBar(0); Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText(""); alert.setContentText(" "); alert.showAndWait(); }); } }.start(); this.Print.setDisable(false); }
From source file:org.martus.client.swingui.PureFxMainWindow.java
@Override public void rawError(String errorText) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("ERROR"); alert.setHeaderText(null);// ww w .j a va2s .c o m alert.setContentText(errorText); alert.showAndWait(); }
From source file:se.trixon.mapollage.ui.MainApp.java
private void displayOptions() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.initOwner(mStage);/*from ww w .j ava2 s . c o m*/ alert.setTitle(Dict.OPTIONS.toString()); alert.setGraphic(null); alert.setHeaderText(null); final DialogPane dialogPane = alert.getDialogPane(); OptionsPanel optionsPanel = new OptionsPanel(); dialogPane.setContent(optionsPanel); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { optionsPanel.save(); } }
From source file:memoryaid.SetReminderController.java
@FXML private void handleSetReminderBtnAction(ActionEvent event) throws Exception { System.out.println("You clicked Add Reminder!"); String rType = (String) reminderTypeBox.getValue(); String rName = reminderNameText.getText(); LocalDate rSDate = startDateId.getValue(); LocalDate rEDate = endDateId.getValue(); List<LocalDate> reminderDates = new ArrayList<>(); String hours = (String) reminderHhBox.getValue(); String minutes = (String) reminderMmBox.getValue(); String seconds = (String) reminderSsBox.getValue(); ObservableList<String> repeat = multiSelectComboBox.getCheckModel().getCheckedItems(); String imgPath = imagePathText.getText(); if (rType == null || rName == null || rSDate == null || rEDate == null || hours == null || minutes == null || seconds == null || repeat.size() == 0 || imgPath == null) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait();/*from w ww . j a v a 2 s. com*/ System.out.println("Please fill all the fields"); } else if (rSDate.isAfter(rEDate) == true) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("End date cannot be before the Start date"); alert.showAndWait(); System.out.println("End date should be greater than start date"); } else { String rTime = hours + ":" + minutes + ":" + seconds; if (rType != null && rName != null && !rName.isEmpty() && rEDate != null && hours != null && minutes != null && seconds != null && repeat != null && imgPath != null) { String destinationPath = "/Users/madhaviunnam/NetBeansProjects/MemoryAid/src/Reminders"; File destinationPathObject = new File(destinationPath + "/" + rName + ".png"); File sourceFilePathObject = new File(imgPath); FileUtils.copyFile(sourceFilePathObject, destinationPathObject); System.out.println( "You clicked Add Reminder!" + rType + rName + rSDate + rEDate + rTime + repeat + imgPath); System.out.println("****Inside if"); Reminder reminderToSet = new Reminder(); reminderToSet.setReminderName(rName); reminderToSet.setReminderType(rType); reminderToSet.setStartDate(rSDate); reminderToSet.setEndDate(rEDate); //endDateToCheck = rEDate.plusDays(1); if (repeat.contains("Every Monday")) { reminderToSet.setRepeatMon("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.MONDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatMon("false"); } if (repeat.contains("Every Tuesday")) { reminderToSet.setRepeatTue("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.TUESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatTue("false"); } if (repeat.contains("Every Wednesday")) { reminderToSet.setRepeatWed("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.WEDNESDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatWed("false"); } if (repeat.contains("Every Thursday")) { reminderToSet.setRepeatThu("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.THURSDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatThu("false"); } if (repeat.contains("Every Friday")) { reminderToSet.setRepeatFri("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.FRIDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatFri("false"); } if (repeat.contains("Every Saturday")) { reminderToSet.setRepeatSat("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SATURDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } rSDate = startDateId.getValue(); } else { reminderToSet.setRepeatSat("false"); } if (repeat.contains("Every Sunday")) { reminderToSet.setRepeatSun("true"); while (rSDate.isBefore(rEDate)) { if (rSDate.getDayOfWeek() == DayOfWeek.SUNDAY) { reminderDates.add(rSDate); } rSDate = rSDate.plusDays(1); } } else { reminderToSet.setRepeatSun("false"); } if (repeat.contains("None")) { reminderToSet.setRepeatNone("true"); reminderDates.add(rSDate); } else { reminderToSet.setRepeatNone("false"); } System.out.println("%%%%Reminder DATes" + reminderDates); reminderToSet.setReminderTime(rTime); reminderToSet.setReminderStatus("New"); DbConnection db = new DbConnection(); Connection conn = db.connect(); PreparedStatement preparedStmt = null; String insertSql = "INSERT into Reminders(ReminderType, ReminderName, StartDate, EndDate, ReminderTime, RepeatM, RepeatT, RepeatW, RepeatTH, RepeatF, RepeatSat, RepeatSun)" + "values(?,?,?,?,?,?,?,?,?,?,?,?)"; preparedStmt = conn.prepareStatement(insertSql); preparedStmt.setString(1, reminderToSet.getReminderType()); preparedStmt.setString(2, reminderToSet.getReminderName()); preparedStmt.setString(3, reminderToSet.getStartDate().toString()); preparedStmt.setString(4, reminderToSet.getEndDate().toString()); preparedStmt.setString(5, reminderToSet.getReminderTime()); preparedStmt.setString(6, reminderToSet.getRepeatMon()); preparedStmt.setString(7, reminderToSet.getRepeatTue()); preparedStmt.setString(8, reminderToSet.getRepeatWed()); preparedStmt.setString(9, reminderToSet.getRepeatThu()); preparedStmt.setString(10, reminderToSet.getRepeatFri()); preparedStmt.setString(11, reminderToSet.getRepeatSat()); preparedStmt.setString(12, reminderToSet.getRepeatSun()); preparedStmt.executeUpdate(); System.out.println("Reminder Inserted Successfully "); //Get the inserted reminders RId String getRIdsql = "Select max(RId) as RId from Reminders"; ResultSet rSet = conn.createStatement().executeQuery(getRIdsql); int newRId = 0; while (rSet.next()) { newRId = rSet.getInt(1); } System.out.println("RID ^^^^^^^^" + newRId); PreparedStatement preparedStmtRDetails = null; for (int i = 0; i < reminderDates.size(); i++) { String rDetailsSql = "Insert into ReminderDetails(RId,DetailNum,ReminderDate,ReminderStatus)" + " values(?,?,?,?)"; preparedStmtRDetails = conn.prepareStatement(rDetailsSql); preparedStmtRDetails.setInt(1, newRId); preparedStmtRDetails.setInt(2, i); preparedStmtRDetails.setString(3, reminderDates.get(i).toString()); preparedStmtRDetails.setString(4, "New"); preparedStmtRDetails.executeUpdate(); System.out.println("ReminderDetails Table Insert Successfull "); } Parent setReminder = FXMLLoader.load(getClass().getResource("SetReminder.fxml")); Scene set_reminder_refresh_scene = new Scene(setReminder); Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); app_stage.hide(); app_stage.setScene(set_reminder_refresh_scene); app_stage.show(); } else { System.out.println("Inside else"); //show alert Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Oops, an Error Dialog"); alert.setContentText("Please fill all the fields"); alert.showAndWait(); } } }
From source file:pah9qdmoviereviews.MovieReviewsFXMLController.java
private void displayErrorAlert(String message) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Error!"); alert.setContentText(message);/*from w w w . j a v a2 s.c o m*/ alert.showAndWait(); }