Java Code Examples for javafx.scene.control.ButtonType#OK
The following examples show how to use
javafx.scene.control.ButtonType#OK .
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: QueryListDialog.java From constellation with Apache License 2.0 | 7 votes |
static String getQueryName(final Object owner, final String[] queryNames) { final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION); final ObservableList<String> q = FXCollections.observableArrayList(queryNames); final ListView<String> nameList = new ListView<>(q); nameList.setCellFactory(p -> new DraggableCell<>()); nameList.setEditable(false); nameList.setOnMouseClicked(event -> { if (event.getClickCount() > 1) { dialog.setResult(ButtonType.OK); } }); dialog.setResizable(false); dialog.setTitle("Query names"); dialog.setHeaderText("Select a query to load."); dialog.getDialogPane().setContent(nameList); final Optional<ButtonType> option = dialog.showAndWait(); if (option.isPresent() && option.get() == ButtonType.OK) { return nameList.getSelectionModel().getSelectedItem(); } return null; }
Example 2
Source File: MenuController.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 3
Source File: JobController.java From Schillsaver with MIT License | 6 votes |
/** * Open a file chooser for the user to select an output directory for * the job. */ private void selectOutputFolder() { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDragEnabled(false); fileChooser.setMultiSelectionEnabled(false); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Directory Selection"); fileChooser.setCurrentDirectory(new File(System.getProperty("user.home"))); fileChooser.setApproveButtonText("Accept"); try { int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { final JobView view = (JobView) super.getView(); view.getTextField_outputFolder().setText(fileChooser.getSelectedFile().getPath() + "/"); } } catch(final HeadlessException e) { final Alert alert = new Alert(Alert.AlertType.ERROR, "There was an issue selecting an output folder.\nSee the log file for more information.", ButtonType.OK); alert.showAndWait(); Settings.getInstance().getLogger().log(e, LogLevel.ERROR); } }
Example 4
Source File: AlertUtil.java From Spring-generator with MIT License | 5 votes |
/** * 确定提示框 * * @param message */ public static boolean showConfirmAlert(String message) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setContentText(message); Optional<ButtonType> optional = alert.showAndWait(); if (ButtonType.OK == optional.get()) { return true; } else { return false; } }
Example 5
Source File: PokemonHomeController.java From dctb-utfpr-2018-1 with Apache License 2.0 | 5 votes |
@FXML private void delPokemonAction() { Pokemon toDelete = (Pokemon) pokemonTable.getSelectionModel().getSelectedItem(); if(toDelete != null) { Alert confirmDelete = new Alert(Alert.AlertType.CONFIRMATION); confirmDelete.setTitle("Confirmar operação."); confirmDelete.setHeaderText("Confirme a operação de deletar."); confirmDelete.setContentText("Deletar Pokemon: "+toDelete.getName()+"?"); Optional<ButtonType> confirm = confirmDelete.showAndWait(); if(confirm.get() == ButtonType.OK) { new PokemonDAO().delete(toDelete); loadPokemonsInTable(); } } }
Example 6
Source File: SetAction.java From MythRedisClient with Apache License 2.0 | 5 votes |
/** * 删除值. * * @param key 数据库中的键 */ @Override public void delValue(String key, boolean selected) { Alert confirmAlert = MyAlert.getInstance(Alert.AlertType.CONFIRMATION); confirmAlert.setTitle("提示"); confirmAlert.setHeaderText(""); confirmAlert.setContentText("将随机删除一个值"); Optional<ButtonType> opt = confirmAlert.showAndWait(); ButtonType rtn = opt.get(); if (rtn == ButtonType.OK) { // 确定 redisSet.pop(key); } }
Example 7
Source File: FXMLParticipantController.java From pikatimer with GNU General Public License v3.0 | 5 votes |
public void clearParticipants(ActionEvent fxevent){ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm Participant Removal"); alert.setHeaderText("This will remove all Participants from the event."); alert.setContentText("This action cannot be undone. Are you sure you want to do this?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ participantDAO.clearAll(); resetForm(); } else { // ... user chose CANCEL or closed the dialog } }
Example 8
Source File: DialogPlus.java From ApkToolPlus with Apache License 2.0 | 5 votes |
/** * 确认对话框 * * @param title 标题 * @param headerText 内容标题,可为null * @param contentText 提示内容 * @param callback 回调 */ public static void confirm(String title, String headerText, String contentText, DialogCallback callback){ Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(title); alert.setHeaderText(headerText); alert.setContentText(contentText); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ callback.callback(DialogCallback.CODE_CONFIRM,null); } else { callback.callback(DialogCallback.CODE_CONCEL,null); } }
Example 9
Source File: BuildsPanel_Controller.java From Path-of-Leveling with MIT License | 5 votes |
@FXML private void deleteBuild(){ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Build delete"); alert.setHeaderText("You are about to delete Build : "+ linker.get(activeBuildID).build.getName()); alert.setContentText("Are you ok with this?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ BuildLinker bl = linker.get(activeBuildID); if(!bl.build.isValid){ root.toggleFooterVisibility(true); } POELevelFx.buildsLoaded.remove(bl.build); sgc.reset(); //buildsBox.getChildren().remove(bl.pec.getRoot()); // remove from the UI buildsBox.getItems().remove(bl.pec.getRoot()); // remove from the UI buildsBox.getSelectionModel().clearSelection(); linker.remove(bl.id); //remove from data root.toggleActiveBuilds(false); if(POELevelFx.buildsLoaded.isEmpty()){ root.toggleAllBuilds(false); } } // and also remove from file system? }
Example 10
Source File: CurrentProjectEditorUIImpl.java From tcMenu with Apache License 2.0 | 5 votes |
@Override public boolean questionYesNo(String title, String header) { logger.log(INFO, "Showing question for confirmation title: {0}, header: {1}", title, header); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(title); alert.setHeaderText(header); return alert.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK; }
Example 11
Source File: MZmineGUI.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public static void requestQuit() { Alert alert = new Alert(AlertType.CONFIRMATION); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(mzMineIcon); alert.setTitle("Confirmation"); alert.setHeaderText("Exit MZmine"); String s = "Are you sure you want to exit?"; alert.setContentText(s); Optional<ButtonType> result = alert.showAndWait(); if ((result.isPresent()) && (result.get() == ButtonType.OK)) { Platform.exit(); System.exit(0); } }
Example 12
Source File: BookListController.java From Library-Assistant with Apache License 2.0 | 5 votes |
@FXML private void handleBookDeleteOption(ActionEvent event) { //Fetch the selected row Book selectedForDeletion = tableView.getSelectionModel().getSelectedItem(); if (selectedForDeletion == null) { AlertMaker.showErrorMessage("No book selected", "Please select a book for deletion."); return; } if (DatabaseHandler.getInstance().isBookAlreadyIssued(selectedForDeletion)) { AlertMaker.showErrorMessage("Cant be deleted", "This book is already issued and cant be deleted."); return; } Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Deleting book"); alert.setContentText("Are you sure want to delete the book " + selectedForDeletion.getTitle() + " ?"); Optional<ButtonType> answer = alert.showAndWait(); if (answer.get() == ButtonType.OK) { Boolean result = DatabaseHandler.getInstance().deleteBook(selectedForDeletion); if (result) { AlertMaker.showSimpleAlert("Book deleted", selectedForDeletion.getTitle() + " was deleted successfully."); list.remove(selectedForDeletion); } else { AlertMaker.showSimpleAlert("Failed", selectedForDeletion.getTitle() + " could not be deleted"); } } else { AlertMaker.showSimpleAlert("Deletion cancelled", "Deletion process cancelled"); } }
Example 13
Source File: CreateNetworkController.java From PeerWasp with MIT License | 5 votes |
private boolean showConfirmDeleteNetworkDialog() { boolean yes = false; Window owner = txtIPAddress.getScene().getWindow(); Alert dlg = DialogUtils.createAlert(AlertType.CONFIRMATION); dlg.initOwner(owner); dlg.setTitle("Delete Network"); dlg.setHeaderText("Delete the network?"); dlg.setContentText("If you go back, your peer will be shut down and your network deleted. Continue?"); dlg.showAndWait(); yes = dlg.getResult() == ButtonType.OK; return yes; }
Example 14
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean checkUnsavedChanges() { clearSelection(); if(editHistory.editStackSize() != savedEditStackSize) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Unsaved changes"); alert.setHeaderText("Unsaved changes"); alert.setContentText("There are unsaved changes, do you want to save them?"); ButtonType discard = new ButtonType("Discard", ButtonData.NO); alert.getButtonTypes().add(discard); Optional<ButtonType> result = alert.showAndWait(); if(result.isPresent()) { if(result.get() == ButtonType.OK) { saveCircuitsInternal(); return saveFile == null; } else { return result.get() == ButtonType.CANCEL; } } } return false; }
Example 15
Source File: DisplayWindow.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void updated(IResourceActionSource source, Resource resource) { if (resource.getFilePath() != null) { File file = resource.getFilePath().toFile(); EditorDockable dockable = findEditorDockable(file); if (dockable != null) { IEditor editor = dockable.getEditor(); if (editor.isDirty() && !editor.isNewFile()) { Optional<ButtonType> option = FXUIUtils.showConfirmDialog(DisplayWindow.this, "File `" + file + "` has been modified outside the editor. Do you want to reload it?", "File being modified", AlertType.CONFIRMATION); if (option.isPresent() && option.get() == ButtonType.OK) { Platform.runLater(() -> editor.refreshResource()); } } else { Platform.runLater(() -> editor.refreshResource()); } } } if (source != navigatorPanel) { navigatorPanel.updated(source, resource); } if (source != suitesPanel) { suitesPanel.updated(source, resource); } if (source != featuresPanel) { featuresPanel.updated(source, resource); } if (source != storiesPanel) { storiesPanel.updated(source, resource); } if (source != issuesPanel) { issuesPanel.updated(source, resource); } }
Example 16
Source File: OverlayStage.java From DeskChan with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean showConfirmation(String text){ Alert alert = new Alert(Alert.AlertType.CONFIRMATION); try { ((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(true); } catch (Exception e){ } alert.setTitle(Main.getString("default_messagebox_name")); alert.setContentText(Main.getString(text)); Optional<ButtonType> result = alert.showAndWait(); return (result.get() != ButtonType.OK); }
Example 17
Source File: Controller.java From uip-pc2 with MIT License | 5 votes |
public void salir(ActionEvent actionEvent) { Alert alerta = new Alert(Alert.AlertType.CONFIRMATION); alerta.setTitle("Pa lante!"); alerta.setContentText("Seguro que te quieres ir"); alerta.setHeaderText("Intento de fuga"); Optional<ButtonType> resultado = alerta.showAndWait(); if (resultado.get() == ButtonType.OK) { Platform.exit(); } int x = Integer.parseInt(campoblanco.getText()); }
Example 18
Source File: UpdateApplication.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void promptForUpdate(final Node node, final Instant new_version) { final File install_location = Locations.install(); // Want to update install_location, but that's locked on Windows, // and replacing the jars of a running application might be bad. // So download into a stage area. // The start script needs to be aware of this stage area // and move it to the install location on startup. final File stage_area = new File(install_location, "update"); final StringBuilder buf = new StringBuilder(); buf.append("You are running version ") .append(TimestampFormats.DATETIME_FORMAT.format(Update.current_version)) .append("\n") .append("The new version is dated ") .append(TimestampFormats.DATETIME_FORMAT.format(new_version)) .append("\n\n") .append("The update will replace the installation in\n") .append(install_location) .append("\n(").append(stage_area).append(")") .append("\nwith the content of ") .append(Update.update_url) .append("\n\n") .append("Do you want to update?\n"); final Alert prompt = new Alert(AlertType.INFORMATION, buf.toString(), ButtonType.OK, ButtonType.CANCEL); prompt.setTitle(NAME); prompt.setHeaderText("A new version of this software is available"); prompt.setResizable(true); DialogHelper.positionDialog(prompt, node, -600, -350); prompt.getDialogPane().setPrefSize(600, 300); if (prompt.showAndWait().orElse(ButtonType.CANCEL) == ButtonType.OK) { // Show job manager to display progress ApplicationService.findApplication(JobViewerApplication.NAME).create(); // Perform update JobManager.schedule(NAME, monitor -> { Update.downloadAndUpdate(monitor, stage_area); Update.adjustCurrentVersion(); if (! monitor.isCanceled()) Platform.runLater(() -> restart(node)); }); } else { // Remove the update button StatusBar.getInstance().removeItem(start_update); start_update = null; } }
Example 19
Source File: Utils.java From blobsaver with GNU General Public License v3.0 | 4 votes |
static void newUnreportableError(String msg) { Alert alert = new Alert(Alert.AlertType.ERROR, msg, ButtonType.OK); alert.showAndWait(); }
Example 20
Source File: DockItemWithInput.java From phoebus with Eclipse Public License 1.0 | 4 votes |
/** Save the content of the item to its current 'input' * * <p>Called by the framework when user invokes the 'Save*' * menu items or when a 'dirty' tab is closed. * * <p>Will never be called when the item remains clean, * i.e. never called {@link #setDirty(true)}. * * @param monitor {@link JobMonitor} for reporting progress * @return <code>true</code> on success */ public final boolean save(final JobMonitor monitor) { // 'final' because any save customization should be possible // inside the save_handler monitor.beginTask(MessageFormat.format(Messages.Saving , input)); try { // If there is no file (input is null or for example http:), // call save_as to prompt for file File file = ResourceParser.getFile(getInput()); if (file == null) return save_as(monitor); if (file.exists() && !file.canWrite()) { // Warn on UI thread that file is read-only final CompletableFuture<ButtonType> response = new CompletableFuture<>(); Platform.runLater(() -> { final Alert prompt = new Alert(AlertType.CONFIRMATION); prompt.setTitle(Messages.SavingAlertTitle); prompt.setResizable(true); prompt.setHeaderText(MessageFormat.format(Messages.SavingAlert , file.toString())); DialogHelper.positionDialog(prompt, getTabPane(), -200, -200); response.complete(prompt.showAndWait().orElse(ButtonType.CANCEL)); }); // If user doesn't want to overwrite, abort the save if (response.get() == ButtonType.OK) return save_as(monitor); return false; } if (save_handler == null) throw new Exception("No save_handler provided for 'dirty' " + toString()); save_handler.run(monitor); } catch (Exception ex) { logger.log(Level.WARNING, "Save error", ex); Platform.runLater(() -> ExceptionDetailsErrorDialog.openError(Messages.SavingHdr, Messages.SavingErr + getLabel(), ex)); return false; } // Successfully saved the file setDirty(false); return true; }