Java Code Examples for javafx.scene.control.TextField#setText()

The following examples show how to use javafx.scene.control.TextField#setText() . 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: StepRepresentationTextBox.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void drawStepContent() {
    super.drawStepContent();

    setNextButtonEnabled(false);

    textField = new TextField();
    textField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (StringUtils.isBlank(newValue)) {
            setNextButtonEnabled(false);
        } else {
            setNextButtonEnabled(true);
        }
    });
    textField.setText(defaultValue);
    textField.setLayoutX(10);
    textField.setLayoutY(40);

    this.addToContentPane(textField);
}
 
Example 2
Source File: ExtractSubAnimationDialog.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
public ExtractSubAnimationDialog(@NotNull final NodeTree<?> nodeTree, @NotNull final AnimationTreeNode node) {
    this.nodeTree = nodeTree;
    this.node = node;

    final Animation animation = node.getElement();
    final AnimControl control = notNull(node.getControl());
    final int frameCount = AnimationUtils.getFrameCount(animation);

    final TextField nameField = getNameField();
    nameField.setText(AnimationUtils.findFreeName(control, Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_NAME_EXAMPLE));

    final IntegerTextField startFrameField = getStartFrameField();
    startFrameField.setMinMax(0, frameCount - 2);
    startFrameField.setValue(0);

    final IntegerTextField endFrameField = getEndFrameField();
    endFrameField.setMinMax(1, frameCount - 1);
    endFrameField.setValue(frameCount - 1);
}
 
Example 3
Source File: Browser.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public void loadPage(TextField textField, //ProgressBar progressBar,
		WebEngine webEngine, WebView webView) {

	String route = textField.getText();
	if (route !=null)
		if (!route.substring(0, 7).equals("http://")) {
			route = "http://" + route;
			textField.setText(route);
		}

	System.out.println("Loading route: " + route);
	//progressBar.progressProperty().bind(webEngine.getLoadWorker().progressProperty());

	webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
		@Override
		public void changed(ObservableValue<? extends State> value,
				State oldState, State newState) {
			if(newState == State.SUCCEEDED){
				System.out.println("Location loaded + " + webEngine.getLocation());
			}
		}
	});
	webEngine.load(route);


}
 
Example 4
Source File: Preferences_Controller.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
private KeyCombination loadKeybinds(Properties prop, String propertyName, TextField kc_field){
    String loadProp = prop.getProperty(propertyName);
    KeyCombination keyCombination = null;
    //this should load the keybind on the controller but not overwrite
    if(loadProp == null){
        //loadProp = hotkeyDefaults.get(propertyName); <- load default or
        return KeyCombination.NO_MATCH;
    }
    try{
        keyCombination = KeyCombination.keyCombination(loadProp);
        System.out.println("-Preferences- Loaded keybind : " + keyCombination.getName() + " for "+ propertyName);
    }catch(Exception e){
        System.out.println("-Preferences- Loading keybind for "+ propertyName+" failed.");
        keyCombination = KeyCombination.NO_MATCH;
    }
    kc_field.setText(loadProp);
    return keyCombination;
}
 
Example 5
Source File: BsqDashboardView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private long updateAveragePriceField(TextField textField, int days, boolean isUSDField) {
    Date pastXDays = getPastDate(days);
    List<TradeStatistics2> bsqTradePastXDays = tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
            .filter(e -> e.getCurrencyCode().equals("BSQ"))
            .filter(e -> e.getTradeDate().after(pastXDays))
            .collect(Collectors.toList());
    List<TradeStatistics2> usdTradePastXDays = tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
            .filter(e -> e.getCurrencyCode().equals("USD"))
            .filter(e -> e.getTradeDate().after(pastXDays))
            .collect(Collectors.toList());
    long average = isUSDField ? getUSDAverage(bsqTradePastXDays, usdTradePastXDays) :
            getBTCAverage(bsqTradePastXDays);
    Price avgPrice = isUSDField ? Price.valueOf("USD", average) :
            Price.valueOf("BSQ", average);
    String avg = FormattingUtils.formatPrice(avgPrice);
    if (isUSDField) {
        textField.setText(avg + " USD/BSQ");
    } else {
        textField.setText(avg + " BSQ/BTC");
    }
    return average;
}
 
Example 6
Source File: LocationPanel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Ask for a path, and return it (possibly return the currentPath.)
 * @param currentPath when entering the method
 * @param dialogTitle to show
 * @param textField to update with the path information
 */
private static void askForPath(final File currentPath, final String dialogTitle, final TextField textField)
{
	GuiAssertions.assertIsJavaFXThread();
	DirectoryChooser directoryChooser = new DirectoryChooser();
	directoryChooser.setInitialDirectory(currentPath);
	directoryChooser.setTitle(dialogTitle);
	File returnFile = directoryChooser.showDialog(null);
	if (returnFile == null)
	{
		returnFile = currentPath;
	}

	textField.setText(returnFile.toString());
}
 
Example 7
Source File: TrafficProfileTestBase.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Add new profile/stream name field
 *
 * @param name
 */
protected void addNewProfileStream(String name) {
    waitForNode("#nameTF");
    TextField nameTF = find("#nameTF");
    nameTF.setText(name);
    Button okButton = find("OK");
    clickOn(okButton);
}
 
Example 8
Source File: ViewerSkin.java    From DashboardFx with GNU General Public License v3.0 5 votes vote down vote up
@Override
void mousePressed() {
    TextField textField = getSkinnable();
    shouldMaskText = false;
    textField.setText(textField.getText());
    shouldMaskText = true;
}
 
Example 9
Source File: IntegerListener.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends String> observable, String oldText, String newText) {
	if (newText.matches("\\d*")) {
		int value = Integer.parseInt(newText);
		action.onChanged(value);
	} else {
		TextField textField = (TextField) observable;
		textField.setText(oldText);
	}
}
 
Example 10
Source File: BrowserTab.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected void addBrowserExeBrowse() {
    String value = BrowserConfig.instance().getValue(getBrowserName(), "browser-exe-path");
    browserExeField = new TextField();
    if (value != null)
        browserExeField.setText(value);
    browseBrowserExeButton = FXUIUtils.createButton("browse", "Select Browser Executable", true, "Browse");
    FileSelectionHandler fileSelectionHandler = new FileSelectionHandler(this, null, null, browseBrowserExeButton,
            "Select Browser executable");
    fileSelectionHandler.setMode(FileSelectionHandler.FILE_CHOOSER);
    browseBrowserExeButton.setOnAction(fileSelectionHandler);
    basicPane.addFormField("Browser Executable:", browserExeField, browseBrowserExeButton);
}
 
Example 11
Source File: DialogBuilder.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
public static DialogBuilder newJumpLineDialog() {
    DialogBuilder dialog = new DialogBuilder("", "Goto line/column ");
    dialog.setToolTip("Enter line:column");
    dialog.setKeyReleaseEvent(LINE_COLUMN_REGEX);
    TextField editor = dialog.getEditor();
    editor.setText("0:0");
    editor.selectAll();
    editor.requestFocus();
    return dialog;
}
 
Example 12
Source File: ImageBackground.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) {
    backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("image.theme.label"));
    backgroundImgLocation.setText(imageName);
    backgroundColorPicker.setValue(Color.BLACK);
    backgroundColorPicker.fireEvent(new ActionEvent());
    backgroundVidLocation.clear();
    vidHueSlider.setValue(0);
    vidStretchCheckbox.setSelected(false);
}
 
Example 13
Source File: CellUtiles.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final TextField textField) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (textField != null) {
                textField.setText(getItemText(cell, converter));
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, textField);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(textField);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
Example 14
Source File: LogbooksTagsView.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Sets the field's text based on the selected items list. */
private void setFieldText(ContextMenu dropDown, List<String> selectedItems, TextField field)
{
    // Handle drop down menu item checking.
    for (MenuItem menuItem : dropDown.getItems())
    {
        CustomMenuItem custom = (CustomMenuItem) menuItem;
        CheckBox check = (CheckBox) custom.getContent();
        // If the item is selected make sure it is checked.

        if (selectedItems.contains(check.getText()))
        {
            if (! check.isSelected())
                check.setSelected(true);
        }
        // If the item is not selected, make sure it is not checked.
        else
        {
            if (check.isSelected())
                check.setSelected(false);
        }
    }

    // Build the field text string.
    String fieldText = "";
    for (String item : selectedItems)
    {
        fieldText += (fieldText.isEmpty() ? "" : ", ") + item;
    }

    field.setText(fieldText);
}
 
Example 15
Source File: MultiplayerClient.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void connectDialog() {

		// Create the custom dialog.
		Dialog<String> dialog = new Dialog<>();
		// Get the Stage.
		Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
/*		
    	stage.setOnCloseRequest(e -> {
			boolean isExit = mainMenu.exitDialog(stage);//.getScreensSwitcher().exitDialog(stage);
			if (!isExit) {
				e.consume();
			}
			else {
				Platform.exit();
			}
		});
*/
		// Add corner icon.
		stage.getIcons().add(new Image(this.getClass().getResource("/icons/network/client48.png").toString()));
		// Add Stage icon
		dialog.setGraphic(new ImageView(this.getClass().getResource("/icons/network/network256.png").toString()));
		// dialog.initOwner(mainMenu.getStage());
		dialog.setTitle("Mars Simulation Project");
		dialog.setHeaderText("Multiplayer Client");
		dialog.setContentText("Enter the host address : ");

		// Set the button types.
		ButtonType connectButtonType = new ButtonType("Connect", ButtonData.OK_DONE);
		// ButtonType localHostButton = new ButtonType("localhost");
		// dialog.getDialogPane().getButtonTypes().addAll(localHostButton,
		// loginButtonType, ButtonType.CANCEL);
		dialog.getDialogPane().getButtonTypes().addAll(connectButtonType, 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 tfUser = new TextField();
		// tfUser.setPromptText("Username");
		TextField tfServerAddress = new TextField();
		// PasswordField password = new PasswordField();
		tfServerAddress.setPromptText("192.168.xxx.xxx");
		tfServerAddress.setText("192.168.xxx.xxx");
		Button localhostB = new Button("Use localhost");

		// grid.add(new Label("Username:"), 0, 0);
		// grid.add(tfUser, 1, 0);
		grid.add(new Label("Server Address:"), 0, 1);
		grid.add(tfServerAddress, 1, 1);
		grid.add(localhostB, 2, 1);

		// Enable/Disable connect button depending on whether the host address
		// was entered.
		Node connectButton = dialog.getDialogPane().lookupButton(connectButtonType);
		connectButton.setDisable(true);

		// Do some validation (using the Java 8 lambda syntax).
		tfServerAddress.textProperty().addListener((observable, oldValue, newValue) -> {
			connectButton.setDisable(newValue.trim().isEmpty());
		} );

		dialog.getDialogPane().setContent(grid);

		// Request focus on the username field by default.
		Platform.runLater(() -> tfServerAddress.requestFocus());

		// Convert the result to a username-password-pair when the login button
		// is clicked.
		dialog.setResultConverter(dialogButton -> {
			if (dialogButton == connectButtonType) {
				return tfServerAddress.getText();
			}
			return null;
		} );

		localhostB.setOnAction(event -> {
			tfServerAddress.setText("127.0.0.1");
		} );
		// localhostB.setPadding(new Insets(1));
		// localhostB.setPrefWidth(10);

		Optional<String> result = dialog.showAndWait();
		result.ifPresent(input -> {
			String serverAddressStr = tfServerAddress.getText();
			this.serverAddressStr = serverAddressStr;
			logger.info("Connecting to server at " + serverAddressStr);
			loginDialog();
		} );

	}
 
Example 16
Source File: ViewerSkin.java    From DashboardFx with GNU General Public License v3.0 4 votes vote down vote up
@Override
void mouseReleased() {
    TextField textField = getSkinnable();
    textField.setText(textField.getText());
    textField.end();
}
 
Example 17
Source File: EditAxis.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private final TextField getBoundField(final Axis axis, final boolean isLowerBound) {
    final TextField textField = new TextField();

    // ValidationSupport has a slow memory leak
    // final ValidationSupport support = new ValidationSupport();
    // final Validator<String> validator = (final Control control, final
    // String value) -> {
    // boolean condition = value == null ? true :
    // !value.matches(NUMBER_REGEX);
    //
    // // additional check in case of logarithmic axis
    // if (!condition && axis.isLogAxis() && Double.parseDouble(value)
    // <= 0) {
    // condition = true;
    // }
    // // change text colour depending on validity as a number
    // textField.setStyle(condition ? "-fx-text-inner-color: red;" :
    // "-fx-text-inner-color: black;");
    // return ValidationResult.fromMessageIf(control, "not a number",
    // Severity.ERROR, condition);
    // };
    // support.registerValidator(textField, true, validator);

    final Runnable lambda = () -> {
        final double value;
        final boolean isInverted = axis.isInvertedAxis();
        if (isLowerBound) {
            value = isInverted ? axis.getMax() : axis.getMin();
        } else {
            value = isInverted ? axis.getMin() : axis.getMax();
        }
        textField.setText(Double.toString(value));
    };

    axis.invertAxisProperty().addListener((ch, o, n) -> lambda.run());
    axis.minProperty().addListener((ch, o, n) -> lambda.run());
    axis.maxProperty().addListener((ch, o, n) -> lambda.run());

    // force the field to be numeric only
    textField.textProperty().addListener((observable, oldValue, newValue) -> {
        if ((newValue != null) && !newValue.matches("\\d*")) {
            final double val;
            try {
                val = Double.parseDouble(newValue);
            } catch (NullPointerException | NumberFormatException e) {
                // not a parsable number
                textField.setText(oldValue);
                return;
            }

            if (axis.isLogAxis() && (val <= 0)) {
                textField.setText(oldValue);
                return;
            }
            textField.setText(Double.toString(val));
        }
    });

    textField.setOnKeyPressed(ke -> {
        if (ke.getCode().equals(KeyCode.ENTER)) {
            final double presentValue = Double.parseDouble(textField.getText());
            if (isLowerBound && !axis.isInvertedAxis()) {
                axis.setMin(presentValue);
            } else {
                axis.setMax(presentValue);
            }
            axis.setAutoRanging(false);

            if (axis instanceof AbstractAxis) {
                // ((AbstractAxis) axis).recomputeTickMarks();
                axis.setTickUnit(((AbstractAxis) axis).computePreferredTickUnit(axis.getLength()));
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("recompute axis tick unit to {}",
                            ((AbstractAxis) axis).computePreferredTickUnit(axis.getLength()));
                }
            }
        }
    });

    HBox.setHgrow(textField, Priority.ALWAYS);
    VBox.setVgrow(textField, Priority.ALWAYS);

    return textField;
}
 
Example 18
Source File: PikaRFIDDirectReader.java    From pikatimer with GNU General Public License v3.0 4 votes vote down vote up
private void setClockDialog(){
    Integer localTZ = TimeZone.getDefault().getOffset(System.currentTimeMillis())/3600000;
    Integer ultraTZ = Integer.parseInt(ultraSettings.get("23"));

    // open a dialog box 
    Dialog<Boolean> dialog = new Dialog();
    dialog.setTitle("Set Ultra Clock");
    dialog.setHeaderText("Set the clock for " + ultraIP);
    ButtonType setButtonType = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(setButtonType, ButtonType.CANCEL);
    
    VBox clockVBox = new VBox();
    clockVBox.setStyle("-fx-font-size: 16px;");
    
    CheckBox useComputer = new CheckBox("Sync with the local computer");
    VBox manualVBox = new VBox();
    manualVBox.setSpacing(5.0);
    manualVBox.disableProperty().bind(useComputer.selectedProperty());
    
    HBox dateHBox = new HBox();
    dateHBox.setSpacing(5.0);
    Label dateLabel = new Label("Date:");
    dateLabel.setMinWidth(40);
    DatePicker ultraDate = new DatePicker();
    dateHBox.getChildren().addAll(dateLabel,ultraDate);
    
    HBox timeHBox = new HBox();
    timeHBox.setSpacing(5.0);
    Label timeLabel = new Label("Time:");
    timeLabel.setMinWidth(40);
    TextField ultraTime = new TextField();
    timeHBox.getChildren().addAll(timeLabel,ultraTime);
    
    HBox tzHBox = new HBox();
    tzHBox.setSpacing(5.0);
    Label tzLabel = new Label("TimeZone:");
    tzLabel.setMinWidth(40);
    Spinner<Integer> tzSpinner = new Spinner<>(-23, 23, localTZ);    
    tzHBox.getChildren().addAll(tzLabel,tzSpinner);

    manualVBox.getChildren().addAll(dateHBox,timeHBox,tzHBox);
    
    CheckBox autoGPS = new CheckBox("Use GPS to auto-set the clock");
    autoGPS.setSelected(true);

    
    clockVBox.getChildren().addAll(useComputer,manualVBox,autoGPS);
    dialog.getDialogPane().setContent(clockVBox);
    
    BooleanProperty timeOK = new SimpleBooleanProperty(false);

    ultraTime.textProperty().addListener((observable, oldValue, newValue) -> {
        timeOK.setValue(false);
        if (DurationParser.parsable(newValue)) timeOK.setValue(Boolean.TRUE);
        if ( newValue.isEmpty() || newValue.matches("^[0-9]*(:?([0-5]?([0-9]?(:([0-5]?([0-9]?)?)?)?)?)?)?") ){
            System.out.println("Possiblely good start Time (newValue: " + newValue + ")");
        } else {
            Platform.runLater(() -> {
                int c = ultraTime.getCaretPosition();
                if (oldValue.length() > newValue.length()) c++;
                else c--;
                ultraTime.setText(oldValue);
                ultraTime.positionCaret(c);
            });
            System.out.println("Bad clock time (newValue: " + newValue + ")");
        }
    });
    
    
    ultraDate.setValue(LocalDate.now());
    ultraTime.setText(LocalTime.ofSecondOfDay(LocalTime.now().toSecondOfDay()).toString());

    Node createButton = dialog.getDialogPane().lookupButton(setButtonType);
    createButton.disableProperty().bind(timeOK.not());
    
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == setButtonType) {
            return Boolean.TRUE;
        }
        return null;
    });

    Optional<Boolean> result = dialog.showAndWait();

    if (result.isPresent()) {
        if (useComputer.selectedProperty().get()) {
            System.out.println("Timezone check: Local :" + localTZ + " ultra: " + ultraTZ);
            if (localTZ.equals(ultraTZ)) setClock(LocalDateTime.now(),null,autoGPS.selectedProperty().get());
            else setClock(LocalDateTime.now(),localTZ,autoGPS.selectedProperty().get());
        } else {
            LocalTime time = LocalTime.MIDNIGHT.plusSeconds(DurationParser.parse(ultraTime.getText()).getSeconds());
            Integer newTZ = tzSpinner.getValue();
            if (newTZ.equals(ultraTZ)) setClock(LocalDateTime.of(ultraDate.getValue(), time),null,autoGPS.selectedProperty().get());
            else {
                setClock(LocalDateTime.of(ultraDate.getValue(), time),newTZ,autoGPS.selectedProperty().get());
            }
        }
        
    }
}
 
Example 19
Source File: FileNameComponent.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public FileNameComponent(int textfieldcolumns, List<File> lastFiles, FileSelectionType type) {
  // setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));

  this.type = type;

  txtFilename = new TextField();
  txtFilename.setPrefColumnCount(textfieldcolumns);
  txtFilename.setFont(smallFont);

  // last used files chooser button
  // on click - set file name to textField
  btnLastFiles = new LastFilesButton("last", file -> txtFilename.setText(file.getPath()));

  Button btnFileBrowser = new Button("...");
  btnFileBrowser.setOnAction(e -> {
    // Create chooser.
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select file");

    // Set current directory.
    final String currentPath = txtFilename.getText();
    if (currentPath.length() > 0) {

      final File currentFile = new File(currentPath);
      final File currentDir = currentFile.getParentFile();
      if (currentDir != null && currentDir.exists()) {
        fileChooser.setInitialDirectory(currentDir);
      }
    }

    // Open chooser.
    File selectedFile = null;
    if(type == FileSelectionType.OPEN)
      selectedFile = fileChooser.showOpenDialog(null);
    else
      selectedFile = fileChooser.showSaveDialog(null);
    
    if (selectedFile == null)
      return;
    txtFilename.setText(selectedFile.getPath());
  });

  getChildren().addAll(txtFilename, btnLastFiles, btnFileBrowser);

  setLastFiles(lastFiles);
}
 
Example 20
Source File: ViewUtil.java    From ClusterDeviceControlPlatform with MIT License 4 votes vote down vote up
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();
    }