Java Code Examples for javafx.scene.Node#setDisable()

The following examples show how to use javafx.scene.Node#setDisable() . 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: LocalSpectralDBSearchParameters.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ExitCode showSetupDialog(boolean valueCheckRequired) {
  if ((getParameters() == null) || (getParameters().length == 0))
    return ExitCode.OK;
  ParameterSetupDialog dialog = new ParameterSetupDialog(valueCheckRequired, this);

  int level = getParameter(msLevel).getValue() == null ? 2 : getParameter(msLevel).getValue();

  IntegerComponent msLevelComp = dialog.getComponentForParameter(msLevel);
  Node mzTolPrecursor = dialog.getComponentForParameter(mzTolerancePrecursor);
  mzTolPrecursor.setDisable(level < 2);
  msLevelComp.getTextField().setOnKeyTyped(e -> {
    try {
      int level2 = Integer.parseInt(msLevelComp.getText());
      mzTolPrecursor.setDisable(level2 < 2);
    } catch (Exception ex) {
      // do nothing user might be still typing
      mzTolPrecursor.setDisable(true);
    }
  });

  dialog.showAndWait();
  return dialog.getExitCode();
}
 
Example 2
Source File: UploadDialog.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
UploadDialog (ScreenWatcher screenWatcher, Path homePath, int baseLength)
{
  super (screenWatcher, homePath, baseLength, "Upload dataset", "PUT");

  labelFromFolder.setFont (labelFont);
  labelFileDate.setFont (labelFont);
  labelDatasetDate.setFont (labelFont);

  grid.add (new Label ("Dataset"), 1, 1);
  grid.add (datasetComboBox, 2, 1);

  grid.add (new Label ("Folder"), 1, 2);
  grid.add (labelFromFolder, 2, 2);

  grid.add (new Label ("File date"), 1, 3);
  grid.add (labelFileDate, 2, 3);

  grid.add (new Label ("Dataset date"), 1, 4);
  grid.add (labelDatasetDate, 2, 4);

  Node okButton = dialog.getDialogPane ().lookupButton (btnTypeOK);
  okButton.setDisable (true);

  labelFileDate.textProperty ().addListener ( (observable, oldValue,
      newValue) -> okButton.setDisable (newValue.trim ().isEmpty ()));

  refreshUpload ();
  datasetComboBox.setOnAction (event -> refreshUpload ());
}
 
Example 3
Source File: QiniuDialog.java    From qiniu with MIT License 5 votes vote down vote up
/**
 * 显示输入密钥的对话框
 *
 * @return 返回用户是否点击确定按钮
 */
public boolean showKeyDialog() {
    ButtonType ok = new ButtonType(QiniuValueConsts.OK, ButtonBar.ButtonData.OK_DONE);
    Dialog<String[]> dialog = getDialog(ok);
    // 文本框
    TextField ak = new TextField();
    ak.setMinWidth(400);
    ak.setPromptText("Access Key");
    TextField sk = new TextField();
    sk.setPromptText("Secret Key");
    // 设置超链接
    Hyperlink hyperlink = new Hyperlink("查看我的KEY:" + QiniuValueConsts.QINIU_KEY_URL);
    hyperlink.setOnAction(event -> QiniuUtils.openLink(QiniuValueConsts.QINIU_KEY_URL));
    // 设置容器
    GridPane grid = Dialogs.getGridPane();
    grid.add(hyperlink, 0, 0, 2, 1);
    grid.add(new Label("Access Key:"), 0, 1);
    grid.add(ak, 1, 1);
    grid.add(new Label("Secret Key:"), 0, 2);
    grid.add(sk, 1, 2);
    Node okButton = dialog.getDialogPane().lookupButton(ok);
    okButton.setDisable(true);
    dialog.getDialogPane().setContent(grid);
    Platform.runLater(ak::requestFocus);
    // 监听文本框的输入状态
    ak.textProperty().addListener((observable, oldValue, newValue) -> okButton.setDisable(newValue.trim().isEmpty() || sk.getText().trim().isEmpty()));
    sk.textProperty().addListener((observable, oldValue, newValue) -> okButton.setDisable(newValue.trim().isEmpty() || ak.getText().trim().isEmpty()));
    // 等待用户操作
    Optional<String[]> result = dialog.showAndWait();
    // 处理结果
    if (result.isPresent() && Checker.isNotEmpty(ak.getText()) && Checker.isNotEmpty(sk.getText())) {
        QiniuApplication.getConfigBean().setAccessKey(ak.getText());
        QiniuApplication.getConfigBean().setSecretKey(sk.getText());
        SdkConfigurer.createAuth(ak.getText(), sk.getText());
        ConfigUtils.writeConfig();
        return true;
    }
    return false;
}
 
Example 4
Source File: SetupDialog.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
private void initDialog() {
    dialog.setHeaderText("Welcome to Archivo");

    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);

    List<Text> text = buildExplanationText();
    TextFlow explanation = new TextFlow(text.toArray(new Text[text.size()]));
    explanation.setPrefWidth(EXPLANATION_WIDTH);
    explanation.setLineSpacing(3);
    grid.add(explanation, 0, 0, 2, 1);

    grid.add(new Label("Media access key"), 0, 1);
    TextField mak = new TextField();
    grid.add(mak, 1, 1);

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    // Only enable the OK button after the user has entered the MAK
    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);
    okButton.setDisable(true);
    mak.textProperty().addListener(((observable, oldValue, newValue) -> {
        okButton.setDisable(newValue.trim().isEmpty());
    }));

    dialog.getDialogPane().setContent(grid);

    Platform.runLater(mak::requestFocus);

    dialog.setResultConverter(button -> {
        if (button == ButtonType.OK) {
            return mak.getText().trim();
        }
        return null;
    });
}
 
Example 5
Source File: UploadDialog.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public UploadDialog (ScreenWatcher screenWatcher, Path homePath, int baseLength)
{
  super (screenWatcher, homePath, baseLength, "Upload dataset", "PUT");

  labelFromFolder.setFont (labelFont);
  labelFileDate.setFont (labelFont);
  labelDatasetDate.setFont (labelFont);

  grid.add (new Label ("Dataset"), 1, 1);
  grid.add (datasetComboBox, 2, 1);

  grid.add (new Label ("Folder"), 1, 2);
  grid.add (labelFromFolder, 2, 2);

  grid.add (new Label ("File date"), 1, 3);
  grid.add (labelFileDate, 2, 3);

  grid.add (new Label ("Dataset date"), 1, 4);
  grid.add (labelDatasetDate, 2, 4);

  Node okButton = dialog.getDialogPane ().lookupButton (btnTypeOK);
  okButton.setDisable (true);

  labelFileDate.textProperty ().addListener ( (observable, oldValue,
      newValue) -> okButton.setDisable (newValue.trim ().isEmpty ()));

  refreshUpload ();
  datasetComboBox.setOnAction (event -> refreshUpload ());
}
 
Example 6
Source File: TakeTwoInputsDialog.java    From Lipi with MIT License 5 votes vote down vote up
public void setupDialog(String firstInputLabel, String firstInputPrompt,
                        String secondInputLabel, String secondInputPrompt) {

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 20, 10, 10));

    grid.add(new Label(firstInputLabel), 0, 0);
    firstInputField = new TextField();
    firstInputField.setPromptText(firstInputPrompt);
    firstInputField.setPrefColumnCount(35);
    grid.add(firstInputField, 1, 0);

    grid.add(new Label(secondInputLabel), 0, 1);
    secondInputField = new TextArea();
    secondInputField.setPrefColumnCount(35);
    secondInputField.setPrefRowCount(1);
    secondInputField.setPromptText(secondInputPrompt);
    grid.add(secondInputField, 1, 1);

    // Enable/Disable login button depending on whether a username was entered.
    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);
    okButton.setDisable(true);

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

    dialog.getDialogPane().setContent(grid);
}
 
Example 7
Source File: MetaDeckView.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
public void deckChanged(MetaDeck metaDeck) {
	for (Node node : contentPane.getChildren()) {
		Deck deck = (Deck) node.getUserData();
		node.setDisable(metaDeck.getDecks().contains(deck));
	}
}
 
Example 8
Source File: BitcoinAddressValidator.java    From thundernetwork with GNU Affero General Public License v3.0 4 votes vote down vote up
private void toggleButtons(String current) {
    boolean valid = testAddr(current);
    for (Node n : nodes) n.setDisable(!valid);
}
 
Example 9
Source File: BitcoinAddressValidator.java    From devcoretalk with GNU General Public License v2.0 4 votes vote down vote up
private void toggleButtons(String current) {
    boolean valid = testAddr(current);
    for (Node n : nodes) n.setDisable(!valid);
}
 
Example 10
Source File: EnabledOnlyWithSources.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public EnabledOnlyWithSources(Node node, PCGenFrame frame)
{
	this.node = node;
	ReferenceFacade<DataSetFacade> loadedDataSetRef = frame.getLoadedDataSetRef();
	node.setDisable(loadedDataSetRef.get() == null);
}
 
Example 11
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 12
Source File: BitcoinAddressValidator.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
private void toggleButtons(String current) {
    boolean valid = testAddr(current);
    for (Node n : nodes) n.setDisable(!valid);
}
 
Example 13
Source File: BitcoinAddressValidator.java    From thunder with GNU Affero General Public License v3.0 4 votes vote down vote up
private void toggleButtons (String current) {
    boolean valid = testAddr(current);
    for (Node n : nodes) {
        n.setDisable(!valid);
    }
}
 
Example 14
Source File: PasswordDialogController.java    From chvote-1-0 with GNU Affero General Public License v3.0 4 votes vote down vote up
private void openPasswordInputDialog(StringProperty target, int groupNumber, boolean withConfirmation) throws ProcessInterruptedException {
    Dialog<String> dialog = new Dialog<>();
    String title = String.format(resources.getString("password_dialog.title"), groupNumber);
    dialog.setTitle(title);
    dialog.getDialogPane().getStylesheets().add("/ch/ge/ve/offlineadmin/styles/offlineadmin.css");
    dialog.getDialogPane().getStyleClass().addAll("background", "password-dialog");

    // Define and add buttons
    ButtonType confirmPasswordButtonType = new ButtonType(resources.getString("password_dialog.confirm_button"), ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(confirmPasswordButtonType, ButtonType.CANCEL);

    // Create header label
    Label headerLabel = new Label(title);
    headerLabel.getStyleClass().add("header-label");

    // Create the input labels and fields
    GridPane grid = new GridPane();
    grid.setHgap(GRID_GAP);
    grid.setVgap(GRID_GAP);
    grid.setPadding(GRID_INSETS);

    TextField electionOfficer1Password = new TextField();
    String electionOfficer1Label = withConfirmation ? resources.getString("password_dialog.election_officer_1")
            : resources.getString("password_dialog.election_officer");
    electionOfficer1Password.setPromptText(electionOfficer1Label);
    electionOfficer1Password.setId("passwordField1");

    TextField electionOfficer2Password = new TextField();
    String electionOfficer2Label = resources.getString("password_dialog.election_officer_2");
    electionOfficer2Password.setPromptText(electionOfficer2Label);
    electionOfficer2Password.setId("passwordField2");

    // Create error message label
    Label errorMessage = createErrorMessage(withConfirmation);
    errorMessage.setId("errorLabel");

    // Position the labels and fields
    int row = 0;
    grid.add(headerLabel, LABEL_COL, row, 2, 1);
    row++;
    grid.add(new Label(electionOfficer1Label), LABEL_COL, row);
    grid.add(electionOfficer1Password, INPUT_COL, row);
    if (withConfirmation) {
        row++;
        grid.add(new Label(electionOfficer2Label), LABEL_COL, row);
        grid.add(electionOfficer2Password, INPUT_COL, row);
    }
    row++;
    grid.add(errorMessage, LABEL_COL, row, 2, 1);

    dialog.getDialogPane().setContent(grid);

    // Perform input validation
    Node confirmButton = dialog.getDialogPane().lookupButton(confirmPasswordButtonType);
    confirmButton.setDisable(true);

    BooleanBinding booleanBinding = bindForValidity(withConfirmation, electionOfficer1Password, electionOfficer2Password, errorMessage, confirmButton);

    // Convert the result
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == confirmPasswordButtonType) {
            return electionOfficer1Password.textProperty().getValueSafe();
        } else {
            return null;
        }
    });

    Platform.runLater(electionOfficer1Password::requestFocus);

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

    //if not disposed then we do have binding errors if this method is run again
    booleanBinding.dispose();
    result.ifPresent(target::setValue);

    if (!result.isPresent()) {
        throw new ProcessInterruptedException("Password input cancelled");
    }
}
 
Example 15
Source File: LoginDialog.java    From zest-writer with GNU General Public License v3.0 4 votes vote down vote up
public LoginDialog(Button googleButton) {
	super(Configuration.getBundle().getString("ui.dialog.auth.title"), Configuration.getBundle().getString("ui.dialog.auth.header"));
       this.config = MainApp.getConfig();

       this.setGraphic(IconFactory.createLoginIcon());

       // Set the button types.
       ButtonType loginButtonType = new ButtonType(Configuration.getBundle().getString("ui.dialog.auth.button"), ButtonData.OK_DONE);
       this.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

       TextField username = new TextField();
       username.setPromptText("username");
       PasswordField password = new PasswordField();
       password.setPromptText("password");
       CheckBox keepConnection = new CheckBox(Configuration.getBundle().getString("ui.dialog.auth.stay"));

       getGridPane().add(googleButton, 0, 0, 1, 2);
       getGridPane().add(new Label(Configuration.getBundle().getString("ui.dialog.auth.username")+":"), 1, 0);
       getGridPane().add(username, 2, 0);
       getGridPane().add(new Label(Configuration.getBundle().getString("ui.dialog.auth.password")+":"), 1, 1);
       getGridPane().add(password, 2, 1);
       getGridPane().add(keepConnection, 2, 2);

       // Enable/Disable login button depending on whether a username was entered.
       Node loginButton = this.getDialogPane().lookupButton(loginButtonType);
       loginButton.setDisable(true);

       keepConnection.selectedProperty().addListener((observable, oldValue, newValue) -> {
           if(keepConnection.isSelected()){
               Alert alert = new CustomAlert(Alert.AlertType.WARNING);
               alert.setTitle(Configuration.getBundle().getString("ui.dialog.warning.title"));
               alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.warning"));

               alert.showAndWait();
           }
       });

       username.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(newValue.trim().isEmpty()));

       this.getDialogPane().setContent(getGridPane());

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

       // Convert the result to a username-password-pair when the login button is clicked.
       this.setResultConverter(dialogButton -> {
           if (dialogButton == loginButtonType) {
               if(keepConnection.isSelected()){
                   config.setAuthentificationUsername(username.getText());
                   config.setAuthentificationPassword(password.getText());
                   config.saveConfFile();
               }

               return new Pair<>(username.getText(), password.getText());
           }
           return null;
       });
}
 
Example 16
Source File: QiniuDialog.java    From qiniu with MIT License 4 votes vote down vote up
/**
 * 显示添加桶的弹窗
 */
public void showBucketDialog() {
    ButtonType ok = new ButtonType(QiniuValueConsts.OK, ButtonBar.ButtonData.OK_DONE);
    Dialog<String[]> dialog = getDialog(ok);
    // 桶名称输入框
    TextField bucket = new TextField();
    bucket.setPromptText(QiniuValueConsts.BUCKET_NAME);
    // 桶域名输入框
    TextField url = new TextField();
    url.setPromptText(QiniuValueConsts.BUCKET_URL);
    // 桶区域输入框
    ComboBox<String> zone = new ComboBox<>();
    zone.getItems().addAll(QiniuValueConsts.BUCKET_NAME_ARRAY);
    zone.setValue(QiniuValueConsts.BUCKET_NAME_ARRAY[0]);
    // 设置容器
    GridPane grid = Dialogs.getGridPane();
    grid.add(new Label(QiniuValueConsts.BUCKET_NAME), 0, 0);
    grid.add(bucket, 1, 0);
    grid.add(new Label(QiniuValueConsts.BUCKET_URL), 0, 1);
    grid.add(url, 1, 1);
    grid.add(new Label(QiniuValueConsts.BUCKET_ZONE_NAME), 0, 2);
    grid.add(zone, 1, 2);
    Node okButton = dialog.getDialogPane().lookupButton(ok);
    okButton.setDisable(true);
    dialog.getDialogPane().setContent(grid);
    Platform.runLater(bucket::requestFocus);
    // 监听文本框的输入状态
    bucket.textProperty().addListener((observable, oldValue, newValue) -> okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty()));
    url.textProperty().addListener((observable, oldValue, newValue) -> okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty()));
    // 结果转换器
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == ok) {
            return new String[]{bucket.getText(), zone.getValue(), (Checker.isHyperLink(url.getText()) ?
                    url.getText() : "example.com")};
        }
        return null;
    });
    // 等待用户操作
    Optional<String[]> result = dialog.showAndWait();
    result.ifPresent(res -> {
        // 处理结果
        Platform.runLater(() -> MainController.getInstance().appendBucket(res[0]));
        BucketBean bucketBean = new BucketBean(res[0], res[1], res[2]);
        QiniuApplication.getConfigBean().getBuckets().add(bucketBean);
        ConfigUtils.writeConfig();
    });
}
 
Example 17
Source File: WebBrowserRepresentation.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public void disableToolbar()
{
    for (Node control : toolbar.getChildren())
        control.setDisable(true);
}
 
Example 18
Source File: EnabledOnlyWithSources.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public EnabledOnlyWithSources(Node node, PCGenFrame frame)
{
	this.node = node;
	ReferenceFacade<DataSetFacade> loadedDataSetRef = frame.getLoadedDataSetRef();
	node.setDisable(loadedDataSetRef.get() == null);
}
 
Example 19
Source File: ViewUtil.java    From ClusterDeviceControlPlatform with MIT License 4 votes vote down vote up
public static Optional<TcpMsgResponseDeviceStatus> ResponseDeviceStatusResult() throws NumberFormatException {
    Dialog<TcpMsgResponseDeviceStatus> 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 textFieldDeviceId = new TextField();
    textFieldDeviceId.setPromptText("1 - 100");

    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(textFieldDeviceId, 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, textFieldDeviceId, textFieldStatus)));
    textFieldDeviceId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
    textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));

    dialog.getDialogPane().setContent(grid);

    // Request focus on the username field by default.
    Platform.runLater(textFieldGroupId::requestFocus);

    dialog.setResultConverter(dialogButton -> {

        if (dialogButton == loginButtonType) {
            try {
                TcpMsgResponseDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseDeviceStatus(Integer.parseInt(
                        textFieldGroupId.getText().trim()),
                        Integer.parseInt(textFieldDeviceId.getText().trim()),
                        Integer.parseInt(textFieldStatus.getText().trim()));
                return tcpMsgResponseDeviceStatus;
            } catch (NumberFormatException e) {
                System.out.println("空");
                return new TcpMsgResponseDeviceStatus(-1, -1, -1);
            }
        }
        return null;
    });
    return dialog.showAndWait();
}
 
Example 20
Source File: BitcoinAddressValidator.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
private void toggleButtons(String current) {
    boolean valid = testAddr(current);
    for (Node n : nodes) n.setDisable(!valid);
}