javafx.scene.control.Dialog Java Examples
The following examples show how to use
javafx.scene.control.Dialog.
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: DialogUtils.java From mapper-generator-javafx with Apache License 2.0 | 7 votes |
public static void closeDialog(Stage primaryStage) { Dialog<ButtonType> dialog = new Dialog<>(); dialog.setTitle("关闭"); dialog.setContentText("确认关闭吗?"); dialog.initOwner(primaryStage); dialog.getDialogPane().getButtonTypes().add(ButtonType.APPLY); dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE); dialog.getDialogPane().setPrefSize(350, 100); Optional<ButtonType> s = dialog.showAndWait(); s.ifPresent(s1 -> { if (s1.equals(ButtonType.APPLY)) { primaryStage.close(); } else if (s1.equals(ButtonType.CLOSE)) { dialog.close(); } }); }
Example #2
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 #3
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 #4
Source File: DialogFactory.java From Motion_Profile_Generator with MIT License | 6 votes |
public static Dialog<Boolean> createSettingsDialog() { Dialog<Boolean> dialog = new Dialog<>(); try { FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/settings/SettingsDialog.fxml") ); dialog.setDialogPane( loader.load() ); ((Button) dialog.getDialogPane().lookupButton(ButtonType.APPLY)).setDefaultButton(true); ((Button) dialog.getDialogPane().lookupButton(ButtonType.CANCEL)).setDefaultButton(false); // Some header stuff dialog.setTitle("Settings"); dialog.setHeaderText("Manage settings"); dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.APPLY ); } catch( Exception e ) { e.printStackTrace(); } return dialog; }
Example #5
Source File: PatchEditorTab.java From EWItool with GNU General Public License v3.0 | 6 votes |
public void mergePatchesUi() { List<String> patchNames = new ArrayList<>(); for (int p = 0; p < EWI4000sPatch.EWI_NUM_PATCHES; p++) patchNames.add( sharedData.ewiPatchList[p].getName() ); Dialog<Integer> mergeDialog = new Dialog<>(); mergeDialog.setTitle( "EWItool - Merge Patches" ); mergeDialog.setHeaderText( "Choose patch to merge with..." ); ListView<String> lv = new ListView<>(); lv.getItems().setAll( patchNames ); // don't need Observable here mergeDialog.getDialogPane().setContent( lv ); mergeDialog.setResultConverter( button -> { if (button == ButtonType.OK) return lv.getSelectionModel().getSelectedIndex(); else return null; } ); mergeDialog.getDialogPane().getButtonTypes().addAll( ButtonType.OK, ButtonType.CANCEL ); Optional<Integer> result = mergeDialog.showAndWait(); if (result.isPresent() && result.get() != -1) { mergeWith( result.get() ); } }
Example #6
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 #7
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 #8
Source File: DialogFactory.java From Motion_Profile_Generator with MIT License | 6 votes |
public static Dialog<Boolean> createAboutDialog() { Dialog<Boolean> dialog = new Dialog<>(); try { FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/about/AboutDialog.fxml") ); dialog.setDialogPane( loader.load() ); dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.CANCEL_CLOSE ); } catch( Exception e ) { e.printStackTrace(); dialog.getDialogPane().getButtonTypes().add( ButtonType.CLOSE ); } dialog.setTitle( "About" ); return dialog; }
Example #9
Source File: ListPickerDialogDemo.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public void start(final Stage stage) { final Button button = new Button("Open Dialog"); final Scene scene = new Scene(new BorderPane(button), 400, 300); stage.setScene(scene); stage.show(); button.setOnAction(event -> { final Dialog<String> dialog = new ListPickerDialog(button, List.of("Apple", "Orange"), "Orange"); dialog.setTitle("Open"); dialog.setHeaderText("Select application for opening\nthe item"); System.out.println(dialog.showAndWait()); }); }
Example #10
Source File: DialogHelper.java From standalone-app with Apache License 2.0 | 6 votes |
public static void enableClosing(Alert alert) { try { Field dialogField = Dialog.class.getDeclaredField("dialog"); dialogField.setAccessible(true); Object dialog = dialogField.get(alert); Field stageField = dialog.getClass().getDeclaredField("stage"); stageField.setAccessible(true); Stage stage = (Stage) stageField.get(dialog); stage.setOnCloseRequest(null); stage.addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> { if (keyEvent.getCode() == KeyCode.ESCAPE) { ((Button) alert.getDialogPane().lookupButton(ButtonType.OK)).fire(); } }); } catch (Exception ex) { // no point ex.printStackTrace(); } }
Example #11
Source File: MainApp.java From zest-writer with GNU General Public License v3.0 | 6 votes |
private void loadCombinason() { scene.addEventFilter(KeyEvent.KEY_PRESSED, t -> { String codeStr = t.getCode().toString(); if(!key.toString().endsWith("_"+codeStr)){ key.append("_").append(codeStr); } }); scene.addEventFilter(KeyEvent.KEY_RELEASED, t -> { if(key.length()>0) { if("_CONTROL_C_L_E_M".equals(key.toString())){ // Create the custom dialog. Dialog<Void> dialog = new Dialog<>(); dialog.setTitle(Configuration.getBundle().getString("ui.menu.easteregg")); dialog.setHeaderText(null); dialog.setContentText(null); dialog.setGraphic(new ImageView(this.getClass().getResource("images/goal.gif").toString())); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK); dialog.showAndWait(); } key = new StringBuilder(); } }); }
Example #12
Source File: MainUIController.java From Motion_Profile_Generator with MIT License | 5 votes |
@FXML private void showAddPointDialog() { Dialog<Waypoint> waypointDialog = DialogFactory.createWaypointDialog(); Optional<Waypoint> result; // Wait for the result result = waypointDialog.showAndWait(); result.ifPresent( (Waypoint w) -> backend.addPoint( w ) ); }
Example #13
Source File: DialogUtils.java From PeerWasp with MIT License | 5 votes |
/** * Decorates a dialog with window icons. * Note: this may not be required anymore with newer Java versions. * * @param dlg the dialog to decorate */ public static void decorateDialogWithIcon(Dialog<?> dlg) { Window window = dlg.getDialogPane().getScene().getWindow(); if (window instanceof Stage) { Stage stage = (Stage) dlg.getDialogPane().getScene().getWindow(); Collection<Image> icons = IconUtils.createWindowIcons(); stage.getIcons().addAll(icons); } }
Example #14
Source File: ViewUtils.java From ApkToolPlus with Apache License 2.0 | 5 votes |
/** * 注册拖拽事件 * * @param dialog * @param root */ public static void registerDragEvent(Dialog dialog, Node root){ // allow the clock background to be used to drag the clock around. final Delta dragDelta = new Delta(); root.setOnMousePressed(mouseEvent -> { // record a delta distance for the drag and drop operation. dragDelta.x = dialog.getX() - mouseEvent.getScreenX(); dragDelta.y = dialog.getY() - mouseEvent.getScreenY(); }); root.setOnMouseDragged(mouseEvent -> { dialog.setX(mouseEvent.getScreenX() + dragDelta.x); dialog.setY(mouseEvent.getScreenY() + dragDelta.y); }); }
Example #15
Source File: PacketHex.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
/** * Show dialog * * @param selectedText * @return */ private String showDialog(String selectedText) { Dialog dialog = new Dialog(); dialog.setTitle("Edit Hex"); dialog.setResizable(false); TextField text1 = new TextField(); text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2)); text1.setText(selectedText); StackPane dialogPane = new StackPane(); dialogPane.setPrefSize(150, 50); dialogPane.getChildren().add(text1); dialog.getDialogPane().setContent(dialogPane); ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); dialog.setResultConverter(new Callback<ButtonType, String>() { @Override public String call(ButtonType b) { if (b == buttonTypeOk) { switch (text1.getText().length()) { case 0: return null; case 1: return "0".concat(text1.getText()); default: return text1.getText(); } } return null; } }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { return result.get(); } return null; }
Example #16
Source File: MZmineGUI.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public static void displayMessage(String msg) { Platform.runLater(() -> { Dialog<ButtonType> dialog = new Dialog<>(); Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); stage.getIcons().add(mzMineIcon); dialog.setTitle("Warning"); dialog.setContentText(msg); dialog.getDialogPane().getButtonTypes().add(ButtonType.OK); dialog.showAndWait(); }); }
Example #17
Source File: Dialogs.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * Initialized a dialog with the given owner window, and String header and content * @param dialog dialog box to initialize * @param window owning window or null if there is none * @param header dialog header * @param content dialog content */ public static void initializeDialog(Dialog dialog, Window window, String header, String content){ if (window != null) dialog.initOwner(window); dialog.setTitle("CPU Sim"); dialog.setHeaderText(header); dialog.setContentText(content); // Allow dialogs to resize for Linux // https://bugs.openjdk.java.net/browse/JDK-8087981 dialog.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); }
Example #18
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 5 votes |
@Override public Dialog gitInformationDialog(String title, String header, String label) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(label); alert.showAndWait(); return alert; }
Example #19
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 5 votes |
public void applyFadeTransition(Dialog node) { FadeTransition fadeTransition = new FadeTransition(); fadeTransition.setDuration(Duration.seconds(.5)); fadeTransition.setNode(node.getDialogPane()); fadeTransition.setFromValue(0); fadeTransition.setToValue(1); fadeTransition.play(); }
Example #20
Source File: MZmineGUI.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public void displayMessage(String title, String msg) { Platform.runLater(() -> { Dialog<ButtonType> dialog = new Dialog<>(); Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); stage.getIcons().add(mzMineIcon); dialog.setTitle(title); dialog.setContentText(msg); dialog.getDialogPane().getButtonTypes().add(ButtonType.OK); dialog.showAndWait(); }); }
Example #21
Source File: SaveLayoutMenuItem.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void positionDialog(final Dialog<?> dialog) { final List<Stage> stages = DockStage.getDockStages(); DialogHelper.positionDialog(dialog, stages.get(0).getScene().getRoot(), -100, -100); dialog.setResizable(true); dialog.getDialogPane().setMinSize(280, 160); }
Example #22
Source File: UserGuiInteractor.java From kafka-message-tool with MIT License | 5 votes |
private static void applyStylesheetTo(Dialog dialog) { DialogPane dialogPane = dialog.getDialogPane(); dialogPane.getStylesheets().add( Thread.currentThread() .getClass() .getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME) .toExternalForm()); }
Example #23
Source File: MainUIController.java From Motion_Profile_Generator with MIT License | 5 votes |
@FXML private void openAboutDialog() { Dialog<Boolean> aboutDialog = DialogFactory.createAboutDialog(); aboutDialog.showAndWait(); }
Example #24
Source File: ViewUtil.java From ClusterDeviceControlPlatform with MIT License | 4 votes |
public static Optional<TcpMsgResponseRandomDeviceStatus> randomDeviceStatus() throws NumberFormatException { Dialog<TcpMsgResponseRandomDeviceStatus> dialog = new Dialog<>(); dialog.setTitle("随机状态信息"); dialog.setHeaderText("随机设备的状态信息"); ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField textFieldGroupId = new TextField(); textFieldGroupId.setPromptText("1 - 120"); TextField textFieldLength = new TextField(); textFieldLength.setPromptText("1 - 60_0000"); TextField textFieldStatus = new TextField(); textFieldStatus.setPromptText("1 - 6"); grid.add(new Label("组号: "), 0, 0); grid.add(textFieldGroupId, 1, 0); grid.add(new Label("范围: "), 0, 1); grid.add(textFieldLength, 1, 1); grid.addRow(2, new Label("状态码: ")); // grid.add(, 0, 2); grid.add(textFieldStatus, 1, 2); // Enable/Disable login button depending on whether a username was entered. Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); textFieldLength.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus))); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(textFieldGroupId::requestFocus); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { try { TcpMsgResponseRandomDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseRandomDeviceStatus(Integer.parseInt( textFieldGroupId.getText().trim()), Integer.parseInt(textFieldStatus.getText().trim()), Integer.parseInt(textFieldLength.getText().trim())); return tcpMsgResponseDeviceStatus; } catch (NumberFormatException e) { System.out.println("空"); return new TcpMsgResponseRandomDeviceStatus(-1, -1, -1); } } return null; }); return dialog.showAndWait(); }
Example #25
Source File: ProjectDirectoryNotSpecifiedDialog.java From paintera with GNU General Public License v2.0 | 4 votes |
public Optional<String> showDialog(final String contentText) throws ProjectDirectoryNotSpecified { if (this.defaultToTempDirectory) { return Optional.of(tmpDir()); } final StringProperty projectDirectory = new SimpleStringProperty(null); final ButtonType specifyProject = new ButtonType("Specify Project", ButtonData.OTHER); final ButtonType noProject = new ButtonType("No Project", ButtonData.OK_DONE); final Dialog<String> dialog = new Dialog<>(); dialog.setResultConverter(bt -> { return ButtonType.CANCEL.equals(bt) ? null : noProject.equals(bt) ? tmpDir() : projectDirectory.get(); }); dialog.getDialogPane().getButtonTypes().setAll(specifyProject, noProject, ButtonType.CANCEL); dialog.setTitle("Paintera"); dialog.setHeaderText("Specify Project Directory"); dialog.setContentText(contentText); final Node lookupProjectButton = dialog.getDialogPane().lookupButton(specifyProject); if (lookupProjectButton instanceof Button) { ((Button) lookupProjectButton).setTooltip(new Tooltip("Look up project directory.")); } Optional .ofNullable(dialog.getDialogPane().lookupButton(noProject)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Create temporary project in /tmp."))); Optional .ofNullable(dialog.getDialogPane().lookupButton(ButtonType.CANCEL)) .filter(b -> b instanceof Button) .map(b -> (Button) b) .ifPresent(b -> b.setTooltip(new Tooltip("Do not start Paintera."))); lookupProjectButton.addEventFilter(ActionEvent.ACTION, event -> { final DirectoryChooser chooser = new DirectoryChooser(); final Optional<String> d = Optional.ofNullable(chooser.showDialog(dialog.getDialogPane().getScene() .getWindow())).map( File::getAbsolutePath); if (d.isPresent()) { projectDirectory.set(d.get()); } else { // consume on cancel, so that parent dialog does not get closed. event.consume(); } }); dialog.setResizable(true); final Optional<String> returnVal = dialog.showAndWait(); if (!returnVal.isPresent()) { throw new ProjectDirectoryNotSpecified(); } return returnVal; }
Example #26
Source File: UserGuiInteractor.java From kafka-message-tool with MIT License | 4 votes |
private static void decorateWithCss(Dialog dialog) { applyStylesheetTo(dialog); }
Example #27
Source File: FormattedDialog.java From archivo with GNU General Public License v3.0 | 4 votes |
public FormattedDialog(Window parent) { dialog = new Dialog<>(); initDialog(parent); }
Example #28
Source File: AboutDialog.java From archivo with GNU General Public License v3.0 | 4 votes |
public AboutDialog(Window parent) { dialog = new Dialog(); initDialog(parent); }
Example #29
Source File: ViewUtil.java From ClusterDeviceControlPlatform with MIT License | 4 votes |
public static Optional<Pair<String, String>> ConnDialogResult() { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("建立连接"); dialog.setHeaderText("请输入服务器的连接信息"); ButtonType loginButtonType = new ButtonType("连接", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField hostName = new TextField(); hostName.setPromptText("localhost"); hostName.setText("localhost"); TextField port = new TextField(); port.setPromptText("30232"); port.setText("30232"); grid.add(new Label("主机名: "), 0, 0); grid.add(hostName, 1, 0); grid.add(new Label("端口号: "), 0, 1); grid.add(port, 1, 1); // Enable/Disable login button depending on whether a username was entered. // Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); // loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). // hostName.textProperty().addListener((observable, oldValue, newValue) -> { // loginButton.setDisable(newValue.trim().isEmpty()); // }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> hostName.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(hostName.getText(), port.getText()); } return null; }); return dialog.showAndWait(); }
Example #30
Source File: GitFxDialog.java From GitFx with Apache License 2.0 | 4 votes |
@Override public Pair<String, String> gitCloneDialog(String title, String header, String content) { Dialog<Pair<String, String>> dialog = new Dialog<>(); DirectoryChooser chooser = new DirectoryChooser(); dialog.setTitle(title); dialog.setHeaderText(header); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField remoteRepo = new TextField(); remoteRepo.setPromptText("Remote Repo URL"); remoteRepo.setPrefWidth(250.0); TextField localPath = new TextField(); localPath.setPromptText("Local Path"); localPath.setPrefWidth(250.0); grid.add(new Label("Remote Repo URL:"), 0, 0); grid.add(remoteRepo, 1, 0); grid.add(new Label("Local Path:"), 0, 1); grid.add(localPath, 1, 1); //ButtonType chooseButtonType = new ButtonType("Choose"); ButtonType cloneButtonType = new ButtonType("Clone"); ButtonType cancelButtonType = new ButtonType("Cancel"); /////////////////////Modification of choose Button//////////////////////// Button chooseButtonType = new Button("Choose"); grid.add(chooseButtonType, 2, 1); chooseButtonType.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { chooser.setTitle(resourceBundle.getString("cloneRepo")); File cloneRepo = chooser.showDialog(dialog.getOwner()); getFileAndSeText(localPath, cloneRepo); } }); ////////////////////////////////////////////////////////////////////// dialog.getDialogPane().setContent(grid); dialog.getDialogPane().getButtonTypes().addAll( cloneButtonType, cancelButtonType); dialog.setResultConverter(dialogButton -> { if (dialogButton == cloneButtonType) { setResponse(GitFxDialogResponse.CLONE); String remoteRepoURL = remoteRepo.getText(); String localRepoPath = localPath.getText(); if (!remoteRepoURL.isEmpty() && !localRepoPath.isEmpty()) { return new Pair<>(remoteRepo.getText(), localPath.getText()); } else { this.gitErrorDialog(resourceBundle.getString("errorClone"), resourceBundle.getString("errorCloneTitle"), resourceBundle.getString("errorCloneDesc")); } } if (dialogButton == cancelButtonType) { //[LOG] logger.debug("Cancel clicked"); setResponse(GitFxDialogResponse.CANCEL); return new Pair<>(null, null); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); Pair<String, String> temp = null; if (result.isPresent()) { temp = result.get(); } return temp; }