List of usage examples for javafx.scene.control ButtonType CANCEL
ButtonType CANCEL
To view the source code for javafx.scene.control ButtonType CANCEL.
Click Source Link
From source file:dev.archiecortez.jfacelog.dialogs.NewPassDialog.java
public NewPassDialog() throws IOException { super();// w w w . j a v a 2s .co m FXMLLoader loader = new FXMLLoader(getClass().getResource("newpassdialog.fxml")); loader.setController(this); Parent root = loader.load(); this.getDialogPane().setContent(root); getDialogPane().getButtonTypes().add(ButtonType.APPLY); getDialogPane().getButtonTypes().add(ButtonType.CANCEL); getDialogPane().lookupButton(ButtonType.APPLY).disableProperty() .bind(newPassword.textProperty().isNotEqualTo(newPasswordCopy.textProperty()) .or(newPassword.textProperty().isEmpty()).or(oldPassword.textProperty().isEmpty())); setResultConverter(value -> { if (value == ButtonType.APPLY) { return new Pair<>(oldPassword.getText(), newPassword.getText()); } else { return null; } }); }
From source file:de.rkl.tools.tzconv.view.ZoneIdSelectionDialog.java
@SuppressWarnings("unused") @PostConstruct// ww w . j ava2 s . com public void initContent() { setOnShowing(this::resetFromModel); getDialogPane().setContent(createZoneIdSelectionBox()); getDialogPane().getButtonTypes().add(ButtonType.OK); getDialogPane().getButtonTypes().add(ButtonType.CANCEL); setResultConverter( buttonType -> buttonType == ButtonType.OK ? newArrayList(pendingSelectedZoneIds.getValue()) : null); }
From source file:de._692b8c32.cdlauncher.MainController.java
public MainController(Application application, Preferences preferences) { this.application = application; this.preferences = preferences; if (preferences.get("basedir", null) == null) { while (new OptionsController(application, preferences).selectDirectory() == null) { new Alert(Alert.AlertType.ERROR, "The launcher needs a directory to store temporary files. Press cancel if you want to close the application.", ButtonType.CANCEL, ButtonType.PREVIOUS).showAndWait().ifPresent(button -> { if (button == ButtonType.CANCEL) { throw new RuntimeException("User requested abort."); }// w w w . j a v a 2 s . co m }); } new Alert(Alert.AlertType.INFORMATION, "Do you want to use a prebuilt version of OpenRA? This is recommended unless you are an OpenRA developer.", ButtonType.NO, ButtonType.YES).showAndWait().ifPresent(button -> { if (button == ButtonType.YES) { preferences.putBoolean("buildFromSources", false); } if (button == ButtonType.NO) { preferences.putBoolean("buildFromSources", true); } }); if (System.getProperty("os.name").toLowerCase().contains("win")) { preferences.put("commandMono", ""); preferences.put("commandMake", ""); } } }
From source file:io.github.mzmine.util.jfreechart.ManualZoomDialog.java
/** * Constructor/*from w w w . j av a2 s. c om*/ */ public ManualZoomDialog(Window parent, XYPlot plot) { initOwner(parent); setTitle("Manual zoom"); setGraphic(new ImageView("file:icons/axesicon.png")); getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); xAxis = (NumberAxis) plot.getDomainAxis(); yAxis = (NumberAxis) plot.getRangeAxis(); try { URL layersDialogFXML = getClass().getResource(DIALOG_FXML); FXMLLoader loader = new FXMLLoader(layersDialogFXML); loader.setController(this); GridPane grid = loader.load(); getDialogPane().setContent(grid); } catch (Exception e) { e.printStackTrace(); } final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK); btOk.addEventFilter(ActionEvent.ACTION, event -> { commitChanges(event); }); }
From source file:eu.over9000.skadi.ui.dialogs.PerformUpdateDialog.java
public PerformUpdateDialog(RemoteVersionResult newVersion) { this.chosen = new SimpleObjectProperty<>( Paths.get(SystemUtils.USER_HOME, newVersion.getVersion() + ".jar").toFile()); this.setHeaderText("Updating to " + newVersion.getVersion()); this.setTitle("Skadi Updater"); this.getDialogPane().getStyleClass().add("alert"); this.getDialogPane().getStyleClass().add("information"); final ButtonType restartButtonType = new ButtonType("Start New Version", ButtonBar.ButtonData.OK_DONE); this.getDialogPane().getButtonTypes().addAll(restartButtonType, ButtonType.CANCEL); Node btn = this.getDialogPane().lookupButton(restartButtonType); btn.setDisable(true);/*from w w w . j a v a2 s. c o m*/ Label lbPath = new Label("Save as"); TextField tfPath = new TextField(); tfPath.textProperty() .bind(Bindings.createStringBinding(() -> this.chosen.get().getAbsolutePath(), this.chosen)); tfPath.setPrefColumnCount(40); tfPath.setEditable(false); Button btChangePath = GlyphsDude.createIconButton(FontAwesomeIcons.FOLDER_OPEN, "Browse..."); btChangePath.setOnAction(event -> { FileChooser fc = new FileChooser(); fc.setTitle("Save downloaded jar.."); fc.setInitialFileName(this.chosen.getValue().getName()); fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("Jar File", ".jar")); fc.setInitialDirectory(this.chosen.getValue().getParentFile()); File selected = fc.showSaveDialog(this.getOwner()); if (selected != null) { this.chosen.set(selected); } }); ProgressBar pbDownload = new ProgressBar(0); pbDownload.setDisable(true); pbDownload.setMaxWidth(Double.MAX_VALUE); Label lbDownload = new Label("Download"); Label lbDownloadValue = new Label(); Button btDownload = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD, "Start"); btDownload.setMaxWidth(Double.MAX_VALUE); btDownload.setOnAction(event -> { btChangePath.setDisable(true); btDownload.setDisable(true); this.downloadService = new DownloadService(newVersion.getDownloadURL(), this.chosen.getValue()); lbDownloadValue.textProperty().bind(this.downloadService.messageProperty()); pbDownload.progressProperty().bind(this.downloadService.progressProperty()); this.downloadService.setOnSucceeded(dlEvent -> { btn.setDisable(false); }); this.downloadService.setOnFailed(dlFailed -> { LOGGER.error("new version download failed", dlFailed.getSource().getException()); lbDownloadValue.textProperty().unbind(); lbDownloadValue.setText("Download failed, check log file for details."); }); this.downloadService.start(); }); final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.add(lbPath, 0, 0); grid.add(tfPath, 1, 0); grid.add(btChangePath, 2, 0); grid.add(new Separator(), 0, 1, 3, 1); grid.add(lbDownload, 0, 2); grid.add(pbDownload, 1, 2); grid.add(btDownload, 2, 2); grid.add(lbDownloadValue, 1, 3); this.getDialogPane().setContent(grid); this.setResultConverter(btnType -> { if (btnType == restartButtonType) { return this.chosen.getValue(); } if (btnType == ButtonType.CANCEL) { if (this.downloadService.isRunning()) { this.downloadService.cancel(); } } return null; }); }
From source file:de.perdoctus.ebikeconnect.gui.dialogs.LoginDialog.java
@PostConstruct public void init() { final ImageView graphic = new ImageView( new Image(getClass().getResource("/app-icon.png").toExternalForm())); graphic.setPreserveRatio(true);/*from ww w. j av a2 s . c o m*/ graphic.setFitHeight(64); setGraphic(graphic); setResizable(true); setWidth(400); setResizable(false); setTitle(rb.getString("dialogTitle")); setHeaderText(rb.getString("dialogMessage")); final ButtonType loginButtonType = new ButtonType(rb.getString("loginButton"), ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 10, 10, 10)); grid.setPrefWidth(getWidth()); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.LEFT, true)); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.ALWAYS, HPos.LEFT, true)); final String rbUsername = rb.getString(CFG_USERNAME); final TextField txtUsername = new TextField(); txtUsername.setPromptText(rbUsername); txtUsername.setText(config.getString(CFG_USERNAME, "")); final Label lblUsername = new Label(rbUsername); lblUsername.setLabelFor(txtUsername); grid.add(lblUsername, 0, 0); grid.add(txtUsername, 1, 0); final String rbPassword = rb.getString(CFG_PASSWORD); final PasswordField txtPassword = new PasswordField(); txtPassword.setPromptText(rbPassword); if (config.getBoolean(CFG_SAVE_PASSWORD, false)) { txtPassword.setText(config.getString(CFG_PASSWORD, "")); } final Label lblPassword = new Label(rbPassword); lblPassword.setLabelFor(txtPassword); grid.add(lblPassword, 0, 1); grid.add(txtPassword, 1, 1); final CheckBox cbSavePassword = new CheckBox(rb.getString("save-password")); cbSavePassword.setSelected(config.getBoolean(CFG_SAVE_PASSWORD, false)); grid.add(cbSavePassword, 1, 2); getDialogPane().setContent(grid); // Enable/Disable login button depending on whether a username was entered. final Node loginButton = getDialogPane().lookupButton(loginButtonType); loginButton.disableProperty() .bind(txtUsername.textProperty().isEmpty().or(txtPassword.textProperty().isEmpty())); setResultConverter(buttonType -> { if (buttonType == loginButtonType) { config.setProperty(CFG_USERNAME, txtUsername.getText()); config.setProperty(CFG_SAVE_PASSWORD, cbSavePassword.isSelected()); if (cbSavePassword.isSelected()) { config.setProperty(CFG_PASSWORD, txtPassword.getText()); config.setProperty(CFG_PASSWORD, txtPassword.getText()); } else { config.clearProperty(CFG_PASSWORD); } return new Credentials(txtUsername.getText(), txtPassword.getText()); } else { return null; } }); if (txtUsername.getText().isEmpty()) { txtUsername.requestFocus(); } else { txtPassword.requestFocus(); txtPassword.selectAll(); } }
From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java
public static DbConfig openDialog(final DbConfig sc) { Dialog<DbConfig> dialog = DialogHelper.createDialog(); dialog.setResizable(false);//from w w w. j a v a2 s . c om final Tuple2<Parent, DbConfigFrmController> tuple = createNewInstance(); if (sc != null) { tuple.get2().loadDataFromSessionConfiguration(sc); } dialog.setTitle(msgDialogTitle); dialog.setHeaderText(msgDialogHeader); dialog.getDialogPane().setContent(tuple.get1()); ButtonType buttonTypeOk = ButtonType.OK; ButtonType buttonTypeCancel = ButtonType.CANCEL; dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); dialog.getDialogPane().setPadding(new Insets(0, 0, 0, 0)); dialog.setResultConverter(b -> { if (b == buttonTypeOk) { DbConfig sc1 = sc; if (sc1 == null) { sc1 = new DbConfig(); tuple.get2().storeDataToSessionConfiguration(sc1); DbConfigFactory.getConfigurations().add(sc1); } else { tuple.get2().storeDataToSessionConfiguration(sc1); if (DbConfigFactory.getConfigurations().contains(sc1)) { // The copied session isn't in list yet int idx = DbConfigFactory.getConfigurations().indexOf(sc1); DbConfigFactory.getConfigurations().remove(sc1); DbConfigFactory.getConfigurations().add(idx, sc1); } else { DbConfigFactory.getConfigurations().add(sc1); } } DbConfigFactory.saveConfiguration(); return sc1; } return null; }); Optional<DbConfig> result = dialog.showAndWait(); if (result.isPresent()) { return result.get(); } return null; }
From source file:cz.lbenda.rcp.DialogHelper.java
/** Open dialog with chooser when user can choose single option * @param question question which is show to user * @param items list of items which user can choose * @param <T> type of item//from www . ja va 2 s . com * @return null if user click on cancel or don't choose anything, elsewhere choosed item */ @SuppressWarnings("unchecked") public static <T> T chooseSingOption(String question, T... items) { if (items.length == 0) { return null; } Dialog<T> dialog = new Dialog<>(); dialog.setResizable(false); dialog.setTitle(chooseSingleOption_title); dialog.setHeaderText(question); ComboBox<T> comboBox = new ComboBox<>(); comboBox.getItems().addAll(items); dialog.getDialogPane().setContent(comboBox); ButtonType btCancel = ButtonType.CANCEL; ButtonType btOk = ButtonType.OK; dialog.getDialogPane().getButtonTypes().addAll(btCancel, btOk); Optional<T> result = dialog.showAndWait(); if (result.isPresent()) { if (btCancel == result.get()) { return null; } if (btOk == result.get()) { return comboBox.getSelectionModel().getSelectedItem(); } } else { return null; } return result.get(); }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
private Optional<String> askUserForTextField(String text) { TextField textfield = new TextField(); Dialog<ButtonType> dialog = new Dialog<>(); dialog.getDialogPane().headerTextProperty().set(text); dialog.getDialogPane().contentProperty().set(textfield); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Optional<ButtonType> result = dialog.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) return Optional.of(textfield.getText()); else//from www . jav a 2s . co m return Optional.empty(); }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
private Optional<String> askUserForTextArea(String label, String initialText) { TextArea textarea = new TextArea(); if (initialText != null) textarea.setText(initialText);//from w ww . java 2 s .c o m Dialog<ButtonType> dialog = new Dialog<>(); dialog.getDialogPane().headerTextProperty().set(label); dialog.getDialogPane().contentProperty().set(textarea); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); Optional<ButtonType> result = dialog.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) return Optional.of(textarea.getText()); else return Optional.empty(); }