javafx.scene.control.ButtonType Java Examples
The following examples show how to use
javafx.scene.control.ButtonType.
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: AlertHelper.java From AsciidocFX with Apache License 2.0 | 7 votes |
public static void showDuplicateWarning(List<String> duplicatePaths, Path lib) { Alert alert = new WindowModalAlert(Alert.AlertType.WARNING); DialogPane dialogPane = alert.getDialogPane(); ListView listView = new ListView(); listView.getStyleClass().clear(); ObservableList items = listView.getItems(); items.addAll(duplicatePaths); listView.setEditable(false); dialogPane.setContent(listView); alert.setTitle("Duplicate JARs found"); alert.setHeaderText(String.format("Duplicate JARs found, it may cause unexpected behaviours.\n\n" + "Please remove the older versions from these pair(s) manually. \n" + "JAR files are located at %s directory.", lib)); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.OK); alert.showAndWait(); }
Example #2
Source File: DisplayWindow.java From marathonv5 with Apache License 2.0 | 7 votes |
private boolean closeEditor(IEditor e) { if (e == null) { return true; } if (e.isDirty()) { Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this, "File \"" + e.getName() + "\" Modified. Do you want to save the changes ", "File \"" + e.getName() + "\" Modified", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); ButtonType shouldSaveFile = result.get(); if (shouldSaveFile == ButtonType.CANCEL) { return false; } if (shouldSaveFile == ButtonType.YES) { File file = save(e); if (file == null) { return false; } EditorDockable dockable = (EditorDockable) e.getData("dockable"); dockable.updateKey(); } } return true; }
Example #3
Source File: DialogControlTest.java From WorkbenchFX with Apache License 2.0 | 6 votes |
@Test void getButton() { // when asking for a button type Optional<Button> button = dialogControl.getButton(BUTTON_TYPE_1); // returns its button in an Optional assertNotEquals(Optional.empty(), button); assertEquals(dialogControl.getButtons().get(0), button.get()); // if the buttonType doesn't exist button = dialogControl.getButton(ButtonType.CANCEL); // return empty optional assertEquals(Optional.empty(), button); // if there are no buttonTypes buttonTypes.clear(); button = dialogControl.getButton(BUTTON_TYPE_1); // return empty optional assertEquals(Optional.empty(), button); }
Example #4
Source File: PaymentController.java From Online-Food-Ordering-System with MIT License | 6 votes |
public static boolean infoBox(String infoMessage, String headerText, String title){ Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setContentText(infoMessage); alert.setTitle(title); alert.setHeaderText(headerText); alert.getButtonTypes(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ // ... user chose OK button return true; } else { // ... user chose CANCEL or closed the dialog return false; } }
Example #5
Source File: FileResource.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) { if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) { option = FXUIUtils.showConfirmDialog(null, "Do you want to delete `" + path + "`?", "Confirm", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL); } if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) { if (Files.exists(path)) { try { Files.delete(path); Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this)); getParent().getChildren().remove(this); } catch (IOException e) { String message = String.format("Unable to delete: %s: %s%n", path, e); FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR); } } } return option; }
Example #6
Source File: DialogHelper.java From mcaselector with MIT License | 6 votes |
public static void importChunks(TileMap tileMap, Stage primaryStage) { File dir = createDirectoryChooser(FileHelper.getLastOpenedDirectory("chunk_import_export")).showDialog(primaryStage); DataProperty<ImportConfirmationDialog.ChunkImportConfirmationData> dataProperty = new DataProperty<>(); if (dir != null) { Optional<ButtonType> result = new ImportConfirmationDialog(primaryStage, dataProperty::set).showAndWait(); result.ifPresent(r -> { if (r == ButtonType.OK) { FileHelper.setLastOpenedDirectory("chunk_import_export", dir.getAbsolutePath()); new CancellableProgressDialog(Translation.DIALOG_PROGRESS_TITLE_IMPORTING_CHUNKS, primaryStage) .showProgressBar(t -> ChunkImporter.importChunks( dir, t, false, dataProperty.get().overwrite(), dataProperty.get().selectionOnly() ? tileMap.getMarkedChunks() : null, dataProperty.get().getRanges(), dataProperty.get().getOffset())); CacheHelper.clearAllCache(tileMap); } }); } }
Example #7
Source File: DeleteLayoutsMenuItem.java From phoebus with Eclipse Public License 1.0 | 6 votes |
DeleteLayoutsDialog() { setTitle(Messages.DeleteLayouts); setHeaderText(Messages.DeleteLayoutsInfo); list.getItems().setAll(memento_files); list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); getDialogPane().setContent(list); getDialogPane().setMinSize(280, 500); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); final Button ok = (Button) getDialogPane().lookupButton(ButtonType.OK); ok.addEventFilter(ActionEvent.ACTION, event -> deleteSelected()); setResultConverter(button -> true); }
Example #8
Source File: TrainingPane.java From OpenLabeler with Apache License 2.0 | 6 votes |
public void onCreateTrainData(ActionEvent actionEvent) { Settings.setTFImageDir(dirTFImage.getText()); Settings.setTFAnnotationDir(dirTFAnnotation.getText()); Settings.setTFDataDir(dirTFData.getText()); File dataDir = new File(Settings.getTFDataDir()); if (dataDir.isDirectory() && dataDir.exists()) { var res = AppUtils.showConfirmation(bundle.getString("label.alert"), bundle.getString("msg.confirmCreateTrainData")); if (res.get() != ButtonType.OK) { return; } } btnCreateTrainData.setDisable(true); TFTrainer.createTrainData(labelMapPane.getItems()); AppUtils.showInformation(bundle.getString("label.alert"), bundle.getString("msg.trainDataCreated")); btnCreateTrainData.setDisable(false); }
Example #9
Source File: DialogUtils.java From qiniu with MIT License | 6 votes |
public static Optional<ButtonType> showException(String header, Exception e) { // 获取一个警告对象 Alert alert = getAlert(header, "错误信息追踪:", AlertType.ERROR); // 打印异常信息 StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); e.printStackTrace(printWriter); String exception = stringWriter.toString(); // 显示异常信息 TextArea textArea = new TextArea(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); GridPane gridPane = new GridPane(); gridPane.setMaxWidth(Double.MAX_VALUE); gridPane.add(textArea, 0, 0); alert.getDialogPane().setExpandableContent(gridPane); return alert.showAndWait(); }
Example #10
Source File: FXMLTimingController.java From pikatimer with GNU General Public License v3.0 | 6 votes |
public void resetTimingLocations(ActionEvent fxevent){ // prompt Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confirm Resetting all Timing Locations"); alert.setHeaderText("This action cannot be undone."); alert.setContentText("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations."); //Label alertContent = new Label("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations."); //alertContent.setWrapText(true); //alert.getDialogPane().setContent(alertContent); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ timingDAO.createDefaultTimingLocations(); } else { // ... user chose CANCEL or closed the dialog } timingLocAddButton.requestFocus(); //timingLocAddButton.setDefaultButton(true); }
Example #11
Source File: FXUIUtils.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public static Optional<ButtonType> showConfirmDialog(Window parent, String message, String title, AlertType type, ButtonType... buttonTypes) { if (Platform.isFxApplicationThread()) { return _showConfirmDialog(parent, message, title, type, buttonTypes); } else { Object r[] = { null }; Object lock = new Object(); synchronized (lock) { Platform.runLater(() -> { r[0] = _showConfirmDialog(parent, message, title, type, buttonTypes); synchronized (lock) { lock.notifyAll(); } }); } synchronized (lock) { try { lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } return (Optional<ButtonType>) r[0]; } }
Example #12
Source File: PropertiesAction.java From phoebus with Eclipse Public License 1.0 | 6 votes |
public FilePropertiesDialog(final File file) { this.file = file; setTitle(Messages.PropDlgTitle); setResizable(true); getDialogPane().setContent(createContent()); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); final Button ok = (Button) getDialogPane().lookupButton(ButtonType.OK); ok.addEventFilter(ActionEvent.ACTION, event -> { if (! updateFile()) event.consume(); }); setResultConverter(button -> null); }
Example #13
Source File: TableManageController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML @Override public void clearAction() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(getBaseTitle()); alert.setContentText(AppVariables.message("SureClear")); 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; } if (clearData()) { clearView(); refreshAction(); } }
Example #14
Source File: RadioChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void onOK(final ActionEvent ignored) { Toggle selectedToggle = toggleGroup.getSelectedToggle(); Logging.debugPrint("selected toggle is " + selectedToggle); if (selectedToggle != null) { Integer whichItemId = (Integer)selectedToggle.getUserData(); InfoFacade selectedItem = chooser.getAvailableList().getElementAt(whichItemId); chooser.addSelected(selectedItem); } if (chooser.isRequireCompleteSelection() && (chooser.getRemainingSelections().get() > 0)) { Dialog<ButtonType> alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(chooser.getName()); alert.setContentText(LanguageBundle.getFormattedString("in_chooserRequireComplete", chooser.getRemainingSelections().get())); alert.showAndWait(); return; } chooser.commit(); committed = true; this.dispose(); }
Example #15
Source File: PreferencesFxDialog.java From PreferencesFX with Apache License 2.0 | 6 votes |
private void setupDialogClose() { dialog.setOnCloseRequest(e -> { LOGGER.trace("Closing because of dialog close request"); ButtonType resultButton = (ButtonType) dialog.resultProperty().getValue(); if (ButtonType.CANCEL.equals(resultButton)) { LOGGER.trace("Dialog - Cancel Button was pressed"); model.discardChanges(); } else { LOGGER.trace("Dialog - Close Button or 'x' was pressed"); if (persistWindowState) { saveWindowState(); } model.saveSettings(); } }); }
Example #16
Source File: SelectRootPathUtils.java From PeerWasp with MIT License | 6 votes |
private static boolean askToCreateDirectory() { boolean yes = false; Alert dlg = DialogUtils.createAlert(AlertType.CONFIRMATION); dlg.setTitle("Create Directory"); dlg.setHeaderText("Create the directory?"); dlg.setContentText("The directory does not exist yet. Do you want to create it?"); dlg.getButtonTypes().clear(); dlg.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); dlg.showAndWait(); yes = dlg.getResult() == ButtonType.YES; return yes; }
Example #17
Source File: MsSpectrumPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public void handleAddScan(Event e) { ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MsSpectrumPlotModule.class); ButtonType exitCode = parameters.showSetupDialog("Add scan"); if (exitCode != ButtonType.OK) return; final RawDataFilesSelection fileSelection = parameters.getParameter(MsSpectrumPlotParameters.inputFiles).getValue(); final Integer scanNumber = parameters.getParameter(MsSpectrumPlotParameters.scanNumber).getValue(); final ScanSelection scanSelection = new ScanSelection(Range.singleton(scanNumber), null, null, null, null, null); final List<RawDataFile> dataFiles = fileSelection.getMatchingRawDataFiles(); boolean spectrumAdded = false; for (RawDataFile dataFile : dataFiles) { for (MsScan scan : scanSelection.getMatchingScans(dataFile)) { String title = MsScanUtils.createSingleLineMsScanDescription(scan); addSpectrum(scan, title); spectrumAdded = true; } } if (!spectrumAdded) { MZmineGUI.displayMessage("Scan not found"); } }
Example #18
Source File: FXMLTimingLocationInputController.java From pikatimer with GNU General Public License v3.0 | 6 votes |
public void removeTimingInput(ActionEvent fxevent){ Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Clear Input..."); alert.setHeaderText("Delete Input:"); alert.setContentText("Do you want to remove the " +timingLocationInput.getLocationName() + " input?\nThis will clear all reads associated with this input."); ButtonType removeButtonType = new ButtonType("Remove",ButtonBar.ButtonData.YES); ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(cancelButtonType, removeButtonType ); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == removeButtonType) { boolean remove = ((VBox) baseGridPane.getParent()).getChildren().remove(baseGridPane); if (timingLocationInput != null) { timingLocationDAO.removeTimingLocationInput(timingLocationInput); } } }
Example #19
Source File: BattleLogScriptController.java From logbook-kai with MIT License | 6 votes |
@FXML void remove() { ButtonType result = Tools.Conrtols.alert(AlertType.CONFIRMATION, "スクリプトの削除", "このスクリプトを削除しますか?", this.getWindow()) .orElse(null); if (!ButtonType.OK.equals(result)) { return; } BattleLogScript selected = this.list.getSelectionModel().getSelectedItem(); if (selected != null) { this.list.getItems().remove(selected); BattleLogScriptCollection.get().getScripts().remove(selected); } if (this.current == selected) { this.setCurrent(null); } }
Example #20
Source File: DesktopBrowserLauncher.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
/** * View a URI in a browser. * * @param uri URI to display in browser. * @throws IOException if browser can not be launched */ private static void viewInBrowser(URI uri) throws IOException { if (Desktop.isDesktopSupported() && DESKTOP.isSupported(Action.BROWSE)) { DESKTOP.browse(uri); } else { Dialog<ButtonType> alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.WARNING)); Logging.debugPrint("unable to browse to " + uri); alert.setTitle(LanguageBundle.getString("in_err_browser_err")); alert.setContentText(LanguageBundle.getFormattedString("in_err_browser_uri", uri)); GuiUtility.runOnJavaFXThreadNow(alert::showAndWait); } }
Example #21
Source File: DialogTestModule.java From WorkbenchFX with Apache License 2.0 | 6 votes |
private void initDialogParts() { // create the data to show in the CheckListView final ObservableList<String> libraries = FXCollections.observableArrayList(); libraries.addAll("WorkbenchFX", "PreferencesFX", "CalendarFX", "FlexGanttFX", "FormsFX"); // Create the CheckListView with the data checkListView = new CheckListView<>(libraries); // initialize map for dialog mapView = new GoogleMapView(); mapView.addMapInializedListener(this); // initialize favorites dialog separately favoriteLibrariesDialog = WorkbenchDialog.builder("Select your favorite libraries", checkListView, Type.INPUT) .onResult(buttonType -> { if (ButtonType.CANCEL.equals(buttonType)) { System.err.println("Dialog was cancelled!"); } else { System.err.println("Chosen favorite libraries: " + checkListView.getCheckModel().getCheckedItems().stream().collect( Collectors.joining(", "))); } }).build(); }
Example #22
Source File: RemoveTagDialog.java From phoebus with Eclipse Public License 1.0 | 6 votes |
public RemoveTagDialog(final Node parent, final Collection<String> tags) { getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); setResizable(true); FXMLLoader loader = new FXMLLoader(); loader.setLocation(this.getClass().getResource("SelectEntity.fxml")); try { getDialogPane().setContent(loader.load()); SelectEntityController controller = loader.getController(); controller.setAvaibleOptions(tags); setResultConverter(button -> { return button == ButtonType.OK ? Tag.Builder.tag(controller.getSelectedOption()).build() : null; }); } catch (IOException e) { // TODO update the dialog logger.log(Level.WARNING, "Failed to remove tag", e); } }
Example #23
Source File: ScanEditor.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public void execute(UndoableAction action) { final ScanInfoModel infos = scan_info_model.get(); if (infos != null) { // Warn that changes to the running scan are limited final Alert dlg = new Alert(AlertType.CONFIRMATION); dlg.setHeaderText(""); dlg.setContentText(Messages.scan_active_prompt); dlg.setResizable(true); dlg.getDialogPane().setPrefSize(600, 300); DialogHelper.positionDialog(dlg, scan_tree, -100, -100); if (dlg.showAndWait().get() != ButtonType.OK) return; // Only property change is possible while running. // Adding/removing commands detaches from the running scan. if (! (action instanceof ChangeProperty)) detachFromScan(); } super.execute(action); }
Example #24
Source File: BaseController.java From MyBox with Apache License 2.0 | 6 votes |
public boolean clearSettings() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(getBaseTitle()); alert.setContentText(AppVariables.message("SureClear")); 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 false; } DerbyBase.clearData(); cleanAppPath(); AppVariables.initAppVaribles(); return true; }
Example #25
Source File: DisplayEditorApplication.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public DisplayEditorInstance create() { if (!AuthorizationService.hasAuthorization("edit_display")) { // User does not have a permission to start editor final Alert alert = new Alert(Alert.AlertType.WARNING); DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100); alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow()); alert.setResizable(true); alert.setTitle(DISPLAY_NAME); alert.setHeaderText(Messages.DisplayApplicationMissingRight); // Autohide in some seconds, also to handle the situation after // startup without edit_display rights but opening editor from memento PauseTransition wait = new PauseTransition(Duration.seconds(7)); wait.setOnFinished((e) -> { Button btn = (Button)alert.getDialogPane().lookupButton(ButtonType.OK); btn.fire(); }); wait.play(); alert.showAndWait(); return null; } return new DisplayEditorInstance(this); }
Example #26
Source File: DatabaseServerController.java From OEE-Designer with MIT License | 6 votes |
@FXML private void onDeleteDataSource() { try { // delete if (dataSource != null) { // confirm ButtonType type = AppUtils.showConfirmationDialog( DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString())); if (type.equals(ButtonType.CANCEL)) { return; } PersistenceService.instance().delete(dataSource); databaseServers.remove(dataSource); onNewDataSource(); } } catch (Exception e) { AppUtils.showErrorDialog(e); } }
Example #27
Source File: QueryListDialog.java From constellation with Apache License 2.0 | 6 votes |
static String getQueryName(final Object owner, final String[] labels) { final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION); dialog.setTitle("Saved JDBC parameters"); final ObservableList<String> q = FXCollections.observableArrayList(labels); final ListView<String> labelList = new ListView<>(q); labelList.setEditable(false); labelList.setOnMouseClicked(event -> { if (event.getClickCount() > 1) { dialog.setResult(ButtonType.OK); } }); dialog.setResizable(false); dialog.setHeaderText("Select a parameter set to load."); dialog.getDialogPane().setContent(labelList); final Optional<ButtonType> option = dialog.showAndWait(); if (option.isPresent() && option.get() == ButtonType.OK) { return labelList.getSelectionModel().getSelectedItem(); } return null; }
Example #28
Source File: NewFXPreloader.java From Path-of-Leveling with MIT License | 5 votes |
@Override public void handleApplicationNotification(PreloaderNotification arg0) { if (arg0 instanceof ProgressNotification) { ProgressNotification pn= (ProgressNotification) arg0; controller.notify(pn.getProgress()); } else if (arg0 instanceof ErrorNotification) { new Alert(Alert.AlertType.ERROR, ((ErrorNotification) arg0).getDetails(), ButtonType.OK).showAndWait(); Platform.exit(); System.exit(1); } else if (arg0 instanceof GemDownloadNotification){ GemDownloadNotification err = (GemDownloadNotification) arg0; controller.gemDownload(err.getGemName()); } }
Example #29
Source File: ListSelectionDialog.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public ListSelectionDialog(final Node root, final String title, final Supplier<ObservableList<String>> available, final Supplier<ObservableList<String>> selected, final Function<String, Boolean> addSelected, final Function<String, Boolean> removeSelected) { this.addSelected = addSelected; this.removeSelected = removeSelected; selectedItems = new ListView<>(selected.get()); // We want to remove items from the available list as they're selected, and add them back as they are unselected. // Due to this we need a copy as available.get() returns an immutable list. availableItems = new ListView<>( FXCollections.observableArrayList(new ArrayList<>(available.get()))); // Remove what's already selected from the available items for (String item : selectedItems.getItems()) availableItems.getItems().remove(item); setTitle(title); final ButtonType apply = new ButtonType(Messages.Apply, ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, apply); getDialogPane().setContent(formatContent()); setResizable(true); DialogHelper.positionAndSize(this, root, PhoebusPreferenceService.userNodeForClass(ListSelectionDialog.class), 500, 600); setResultConverter(button -> button == apply); }
Example #30
Source File: AppUtils.java From java-ml-projects with Apache License 2.0 | 5 votes |
public static boolean askIfOk(String msg) { Alert dialog = new Alert(AlertType.CONFIRMATION); dialog.setTitle("Confirmation"); dialog.setResizable(true); dialog.setContentText(msg); dialog.setHeaderText(null); dialog.showAndWait(); return dialog.getResult() == ButtonType.OK; }