Java 类javafx.scene.control.PasswordField 实例源码

项目:Notebook    文件:SettingFragment.java   
@Override
public void initData(Parent node, Map<String, String> bundle) {
    et_download_path = (TextField) node.lookup("#et_download_path");
    et_deploy_path = (TextField) node.lookup("#et_deploy_path");
    et_secret = (TextField) node.lookup("#et_secret");
    et_git_username = (TextField) node.lookup("#et_git_username");
    et_git_passwd = (PasswordField) node.lookup("#et_git_passwd");
    et_app_password = (PasswordField) node.lookup("#et_app_password");
    et_app_password_second = (PasswordField) node.lookup("#et_app_password_second");
    btn_submit = (Button) node.lookup("#btn_submit");

    readFromProperty();

    btn_submit.setOnAction(e->{
        String message = "";
        if(!et_app_password.getText().trim().equals(et_app_password_second.getText().trim())){
            message = "�����������벻һ�£�";
            DialogHelper.alert("����", message);
            return;
        }
        if(!"".equals(et_app_password.getText().trim()) && et_app_password.getText().trim().length() < 5){
            message = "���볤��̫��,������ȫ��";
            DialogHelper.alert("����", message);
            return;
        }

        writeToProperty();
    });


}
项目:MythRedisClient    文件:ConnectController.java   
/**
 * 确认两次密码是否一致.
 * @param password 密码输入框
 * @param rePassword 确认密码输入框
 */
private void confirmPassword(PasswordField password, PasswordField rePassword,
                             Label label, boolean[] ok) {
    rePassword.focusedProperty().addListener(
        (observable, oldValue, newValue) -> {
            if (!rePassword.getText().equals(password.getText())) {
                label.setText("两次密码不一致");
                label.setTextFill(Color.rgb(255, 0, 0));
                ok[0] = false;
                return;
            }
            label.setText("");
            ok[0] = true;
        }
    );
}
项目:marathonv5    文件:PasswordFiledSample.java   
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);
    stage.setTitle("Password Field Sample");

    VBox vb = new VBox();
    vb.setPadding(new Insets(10, 0, 0, 10));
    vb.setSpacing(10);
    HBox hb = new HBox();
    hb.setSpacing(10);
    hb.setAlignment(Pos.CENTER_LEFT);

    Label label = new Label("Password");
    final PasswordField pb = new PasswordField();  
    pb.setText("Your password");

    pb.setOnAction((ActionEvent e) -> {
        if (!pb.getText().equals("T2f$Ay!")) {
            message.setText("Your password is incorrect!");
            message.setTextFill(Color.rgb(210, 39, 30));
        } else {
            message.setText("Your password has been confirmed");
            message.setTextFill(Color.rgb(21, 117, 84));
        }
        pb.clear();
    });

    hb.getChildren().addAll(label, pb);
    vb.getChildren().addAll(hb, message);

    scene.setRoot(vb);
    stage.show();
}
项目:Goliath-Overclocking-Utility-FX    文件:PasswordPane.java   
public PasswordPane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    super.getStyleClass().add("pane");
    super.setPadding(new Insets(15,15,15,15));
    super.setVgap(10);

    buttons = new HBox();
    buttons.setSpacing(10);

    Label promptText = new Label("Sudo required.");

    okButton = new Button("OK");
    cancelButton = new Button("Cancel");

    buttons.getChildren().addAll(okButton, cancelButton);

    password = new PasswordField();

    okButton.setPrefWidth(60);
    okButton.setOnMouseClicked(new OkButtonHandler());

    cancelButton.setOnMouseClicked(new CancelButtonHandler());

    password.setPromptText("Password");

    super.add(promptText, 0, 0);
    super.add(password, 0, 1);
    super.add(buttons, 0, 2);

}
项目:Game-Engine-Vooga    文件:LoginScreen.java   
private HBox userInput () {
    HBox input = new HBox(TEXT_SPACING);

    myMakeUsername = new TextField();
    myMakeUsername.setPromptText(USR);
    myMakeDisplayname = new TextField();
    myMakeDisplayname.setPromptText("Display Name");
    myMakePassword = new PasswordField();
    myMakePassword.setPromptText(PS);

    input.getChildren().addAll(myMakeUsername, myMakeDisplayname, myMakePassword);
    input.setAlignment(Pos.CENTER);
    input.setPrefHeight(HEIGHT / 2);

    return input;
}
项目:rpmjukebox    文件:SettingsControllerTest.java   
@Test
public void shouldClickOkButtonWhenProxyPasswordIsInvalid() {
    PasswordField proxyPasswordTextField = find("#proxyPasswordTextField");
    proxyPasswordTextField.setText(StringUtils.repeat('x', 256));

    SystemSettings mockSystemSettings = mock(SystemSettings.class);
    when(mockSettingsManager.getSystemSettings()).thenReturn(mockSystemSettings);

    clickOn("#okButton");

    verify(mockSystemSettings, never()).setCacheSizeMb(anyInt());
    verify(mockSystemSettings, never()).setProxyHost(anyString());
    verify(mockSystemSettings, never()).setProxyPort(anyInt());
    verify(mockSystemSettings, never()).setProxyRequiresAuthentication(anyBoolean());
    verify(mockSystemSettings, never()).setProxyUsername(anyString());
    verify(mockSystemSettings, never()).setProxyPassword(anyString());
    verify(mockSettingsManager, never()).saveSystemSettings();
    verify(spySettingsView, never()).close();
}
项目:bunkr    文件:PasswordDialog.java   
@Override
public void initControls()
{
    this.topLabel = new Label("This archive requires a password. Please enter a password or provide a path to a file containing the password.");
    this.topLabel.setWrapText(true);
    this.passwordLabel = new Label("Password:");
    this.passwordFileLabel = new Label("Password File:");
    this.passwordField = new PasswordField();
    this.passwordFilePathBox = new TextField();
    this.passwordFilePathBox.setEditable(false);
    this.pickPasswordFileButton = Icons.buildIconButton("Select", Icons.ICON_ELLIPSIS);
    this.passwordFilePathBox.setFocusTraversable(false);
    this.cancelButton = Icons.buildIconButton("Cancel", Icons.ICON_CROSS);
    this.continueButton = Icons.buildIconButton("Continue", Icons.ICON_TICK);
    this.continueButton.setDisable(true);
}
项目:PeerWasp    文件:CombinedPasswordValidator.java   
public CombinedPasswordValidator(PasswordField txtPassword,
        StringProperty passwordErrorProperty, PasswordField txtConfirmPassword) {
    validatePassword = new TextFieldValidator(txtPassword, passwordErrorProperty, true) {
        @Override
        public ValidationResult validate(String password) {
            final String confirmPassword = validateConfirmPassword.getTextField().getText();
            return validatePasswords(password, confirmPassword);
        }
    };

    validateConfirmPassword = new TextFieldValidator(txtConfirmPassword) {
        @Override
        public ValidationResult validate(String confirmPassword) {
            final String password = validatePassword.getTextField().getText();
            return validatePasswords(password, confirmPassword);
        }
    };
}
项目:PeerWasp    文件:CombinedPinValidator.java   
public CombinedPinValidator(PasswordField txtPin,
        StringProperty pinErrorProperty, PasswordField txtConfirmPin) {
    validatePin = new TextFieldValidator(txtPin, pinErrorProperty, true) {
        @Override
        public ValidationResult validate(String pin) {
            final String confirmPin = validateConfirmPin.getTextField().getText();
            return validatePins(pin, confirmPin);
        }
    };

    validateConfirmPin = new TextFieldValidator(txtConfirmPin) {
        @Override
        public ValidationResult validate(String confirmPin) {
            final String pin = validatePin.getTextField().getText();
            return validatePins(pin, confirmPin);
        }
    };
}
项目:marathonv5    文件:JavaFXPasswordFieldElementTest.java   
@Test public void marathon_select() {
    PasswordField passwordFieldNode = (PasswordField) getPrimaryStage().getScene().getRoot().lookup(".password-field");
    passwordField.marathon_select("Hello World");
    new Wait("Waiting for the password field value to be set") {
        @Override public boolean until() {
            return "Hello World".equals(passwordFieldNode.getText());
        }
    };
}
项目:marathonv5    文件:JavaFXPasswordFieldElementTest.java   
@Test public void clear() {
    PasswordField passwordFieldNode = (PasswordField) getPrimaryStage().getScene().getRoot().lookup(".password-field");
    passwordField.marathon_select("Hello World");
    new Wait("Waiting for the password field value to be set") {
        @Override public boolean until() {
            return "Hello World".equals(passwordFieldNode.getText());
        }
    };
    passwordField.clear();
    new Wait("Waiting for the password field value to be cleared") {
        @Override public boolean until() {
            return "".equals(passwordFieldNode.getText());
        }
    };
}
项目:marathonv5    文件:JavaFXPasswordFieldElementTest.java   
@Test public void getText() {
    PasswordField passwordFieldNode = (PasswordField) getPrimaryStage().getScene().getRoot().lookup(".password-field");
    AssertJUnit.assertEquals("", passwordField.getText());
    passwordField.marathon_select("Hello World");
    new Wait("Waiting for the password field value to be set") {
        @Override public boolean until() {
            return "Hello World".equals(passwordFieldNode.getText());
        }
    };
    AssertJUnit.assertEquals("Hello World", passwordField.getText());
}
项目:marathonv5    文件:PasswordFieldSample.java   
public PasswordFieldSample() {
    PasswordField passwordFiled = new PasswordField();
    passwordFiled.setMaxSize(250, 250);
    VBox root = new VBox();
    root.getChildren().addAll(passwordFiled, new Button("Click Me!!"));
    getChildren().add(root);
}
项目:MasterHash    文件:NewLogin.java   
public static void display() {
    window = new Stage();
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Log In");
    HEADING = "New Login";

    Label headingLabel = new Label(HEADING);
    headingLabel.setFont(Font.font("Verdana", FontWeight.BOLD, 30));

    TextField nameTextField = new TextField();
    nameTextField.setPromptText("Name");

    TextField userNameTextField = new TextField();
    userNameTextField.setPromptText("Username");

    PasswordField passwordField = new PasswordField();
    passwordField.setPromptText("Password");
    Button generateButton = new Button("Generate");

    HBox generatePasswordArea = new HBox();
    generatePasswordArea.getChildren().addAll(passwordField, generateButton);

    Button submitButton = new Button("Submit");

    VBox layout = new VBox(10);
    layout.setPadding(new Insets(0, 20, 0, 20));
    layout.setAlignment(Pos.CENTER_LEFT);
    layout.getChildren().addAll(headingLabel, nameTextField, userNameTextField, generatePasswordArea, submitButton);

    Scene scene = new Scene(layout, 300, 400);
    window.setScene(scene);
    window.showAndWait();
}
项目:CyberTigerScoreboard    文件:PasswordDialog.java   
public PasswordDialog(String whatFor) {
  setTitle(whatFor+" Password");
  setHeaderText("Please enter your "+whatFor+" password: ");

  ButtonType passwordButtonType = new ButtonType("Login", ButtonData.OK_DONE);
  getDialogPane().getButtonTypes().addAll(passwordButtonType, ButtonType.CANCEL);

  passwordField = new PasswordField();
  passwordField.setPromptText(whatFor+" password");

  HBox hBox = new HBox();
  hBox.getChildren().add(passwordField);
  hBox.setPadding(new Insets(20));

  HBox.setHgrow(passwordField, Priority.ALWAYS);

  getDialogPane().setContent(hBox);

  Platform.runLater(() -> passwordField.requestFocus());

  setResultConverter(dialogButton -> {
    if (dialogButton == passwordButtonType) {
      return passwordField.getText();
    }
    return "";
  });
}
项目:voogasalad-ltub    文件:PasswordManager.java   
public PasswordManager(UsersModel userModel, UserCallback onSuccess){
    txtUserName = new TextField();
    lblMessage = new Label();
    pf = new PasswordField();
    this.usersModel= userModel; 
    this.onSuccess = onSuccess;     
    show();
}
项目:Game-Engine-Vooga    文件:LoginScreen.java   
private HBox loginInput () {
    HBox input = new HBox(TEXT_SPACING);

    myLoginUsername = new TextField();
    myLoginUsername.setPromptText(USR);
    myLoginPassword = new PasswordField();
    myLoginPassword.setPromptText(PS);

    input.getChildren().addAll(myLoginUsername, myLoginPassword);
    input.setAlignment(Pos.CENTER);
    input.setPrefHeight(HEIGHT / 2);

    return input;
}
项目:Lernkartei    文件:RegisterView.java   
@Override
public Parent constructContainer()
{
    bp.setId("registerviewbg");

    AllFields = new VBox(50);
    AllFields.setAlignment(Pos.CENTER);
    AllFields.setMaxWidth(300);
    AllFields.setPadding(new Insets(20));

    Controls = new HBox(50);
    Controls.setAlignment(Pos.CENTER);
    Controls.setPadding(new Insets(20));

    txtName = new TextField();
    txtName.setPromptText("Username");
    pwPassword = new PasswordField();
    pwPassword.setPromptText("Passwort");
    pwToCheck = new PasswordField();
    pwToCheck.setPromptText("Passwort wiederholen");
    txtMail = new TextField();
    txtMail.setPromptText("E-Mail");

    reg = new AppButton("Registrieren");
    home = new HomeButton(getFXController());

    AllFields.getChildren().addAll(txtName, pwPassword, pwToCheck, txtMail, reg);
    Controls.getChildren().addAll(home);

    bp.setBottom(Controls);
    bp.setCenter(AllFields);

    return bp;
}
项目:openjfx-8u-dev-tests    文件:PasswordFieldApp.java   
protected Object createObject(double width, double height) {
    PasswordField passwordField = new PasswordField();
    passwordField.setText(text);
    passwordField.setMinSize(width, height);
    passwordField.setPrefSize(width, height);
    passwordField.setMaxSize(width, height);
    return passwordField;
}
项目:openjfx-8u-dev-tests    文件:Change.java   
public void apply(Type node, boolean internal) {
    if (node.getClass().equals(TextInputExternalWrap.class)) {
        isPasswordField = ((TextInputControlWrapInterface) node).getControl() instanceof PasswordField;
    }
    this.internal = internal;
    apply(node);
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
private boolean isPasswordField() {
    return new GetAction<Boolean>() {
        @Override
        public void run(Object... os) throws Exception {
            setResult(PasswordField.class.isAssignableFrom(taTesting.getControl().getClass()));
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:ControlsCssStylesFactory.java   
@Override
public void decorate(Node control, Pane container) {
    if (control instanceof PasswordField) {
        ((PasswordField) control).setText("12345");
    }
    super.decorate(control, container);
}
项目:rpmjukebox    文件:SettingsControllerTest.java   
@Test
public void shouldClickOkButton() {
    TextField cacheSizeMbTextField = find("#cacheSizeMbTextField");
    cacheSizeMbTextField.setText("250");
    TextField proxyHostTextField = find("#proxyHostTextField");
    proxyHostTextField.setText("localhost");
    TextField proxyPortTextField = find("#proxyPortTextField");
    proxyPortTextField.setText("8080");
    CheckBox proxyAuthCheckBox = find("#proxyAuthCheckBox");
    proxyAuthCheckBox.setSelected(true);
    TextField proxyUsernameTextField = find("#proxyUsernameTextField");
    proxyUsernameTextField.setText("username");
    PasswordField proxyPasswordTextField = find("#proxyPasswordTextField");
    proxyPasswordTextField.setText("password");

    SystemSettings mockSystemSettings = mock(SystemSettings.class);
    when(mockSettingsManager.getSystemSettings()).thenReturn(mockSystemSettings);

    clickOn("#okButton");

    verify(mockSystemSettings, times(1)).setCacheSizeMb(250);
    verify(mockSystemSettings, times(1)).setProxyHost("localhost");
    verify(mockSystemSettings, times(1)).setProxyPort(8080);
    verify(mockSystemSettings, times(1)).setProxyRequiresAuthentication(true);
    verify(mockSystemSettings, times(1)).setProxyUsername("username");
    verify(mockSystemSettings, times(1)).setProxyPassword("password");
    verify(mockSettingsManager, times(1)).saveSystemSettings();
    verify(spySettingsView, times(1)).close();
}
项目:NoticEditor    文件:PasswordDialog.java   
public PasswordDialog(String defaultValue) {
    setHeaderText("Enter password");
    passwordField = new PasswordField();
    passwordField.setText(defaultValue);
    getDialogPane().setContent(passwordField);
    getDialogPane().getButtonTypes().add(ButtonType.OK);
    getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
    Platform.runLater(() -> passwordField.requestFocus());

    setResultConverter(param -> param == ButtonType.OK ? passwordField.getText() : null);
}
项目:bgfinancas    文件:Validar.java   
public static void passwordField(PasswordField senha) throws Erro{
    if(senha.getText().equals("")){
        Janela.showTooltip(Status.ADVERTENCIA, idioma.getMensagem("campo_nao_informado"), senha, Duracao.CURTA);
        senha.requestFocus();
        throw new Erro();
    }
}
项目:bgfinancas    文件:Validar.java   
public static void passwordField(PasswordField senha, PasswordField senha_confirmar) throws Erro{
    Validar.passwordField(senha);
    if(!senha.getText().equals(senha_confirmar.getText())){
        Janela.showTooltip(Status.ADVERTENCIA, idioma.getMensagem("senhas_diferentes"), senha, Duracao.CURTA);
        senha.requestFocus();
        throw new Erro();
    }
}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetPasswordFieldAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(PasswordField.class);

    assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
项目:cate    文件:PasswordInputDialog.java   
public PasswordInputDialog() {
    super();
    pass = new PasswordField();
    grid = new GridPane();
    heading = new Label();

    heading.getStyleClass().add("label-heading");
    contentTextProperty().addListener((observable, oldVal, newVal) -> {
        heading.setText(newVal);
    });

    grid.setHgap(MainController.DIALOG_HGAP);
    grid.setVgap(MainController.DIALOG_VGAP);
    grid.addRow(0, heading, pass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(pass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            return pass.getText();
        }
        return null;
    });
}
项目:cate    文件:DualPasswordInputDialog.java   
public DualPasswordInputDialog(final ResourceBundle resources) {
    super();

    newLabel = new Label(resources.getString("dialogEncrypt.passNew"));
    repeatLabel = new Label(resources.getString("dialogEncrypt.passRepeat"));
    newPass = new PasswordField();
    repeatPass = new PasswordField();

    newLabel.getStyleClass().add("label-heading");
    repeatLabel.getStyleClass().add("label-heading");

    grid = new GridPane();
    grid.setHgap(DIALOG_HGAP);
    grid.setVgap(DIALOG_VGAP);
    grid.addRow(0, newLabel, newPass);
    grid.addRow(1, repeatLabel, repeatPass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(newPass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            if (!newPass.getText().trim().isEmpty() && !repeatPass.getText().trim().isEmpty()) {
                if (Objects.equals(newPass.getText(), repeatPass.getText())) {
                    return newPass.getText();
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
        return null;
    });
}
项目:javafx-demos    文件:GridPaneExample2.java   
@Override
public void start(Stage primaryStage) throws Exception
{
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(40, 0, 0, 50));
    //gridPane.setHgap(5); 
    //gridPane.setVgap(5);
    gridPane.setGridLinesVisible(true);

    Scene scene = new Scene(gridPane, 300, 150);

    Label lbUser = new Label("Username:");
    GridPane.setHalignment(lbUser, HPos.RIGHT);
    //TextField tfUser = new TextField();
    ScrollFreeTextArea tfUser = new ScrollFreeTextArea();

    Label lbPass = new Label("Password:");
    GridPane.setHalignment(lbPass, HPos.RIGHT);
    PasswordField tfPass = new PasswordField();

    Button btLogin = new Button("Login");
    GridPane.setMargin(btLogin, new Insets(10, 0, 0, 0));

    gridPane.add(lbUser, 0, 0);
    gridPane.add(tfUser, 1, 0);
    gridPane.add(lbPass, 0, 1);
    gridPane.add(tfPass, 1, 1);
    gridPane.add(btLogin, 1, 2);

    primaryStage.setTitle("GridPaneExample 1");
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:botcoin    文件:PassphraseDialog.java   
private Node addGridPane() {
  //see http://docs.oracle.com/javafx/2/ui_controls/editor.htm

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

   infoLabel = new Label("Insert a passphrase to encrypt your data and protect the application. \n"
           + " Use your fantasy but don't forget it, \n"
           + " you will need it to open the application.\n "
           + " Passphrase must contain at least "+Settings.MIN_PASS_LENGTH+" characters."); 

   passphraseField = new PasswordField(); passphraseField.setPromptText("Insert your encription passphrase");
   passphrase2Field = new PasswordField(); passphrase2Field.setPromptText("Confirm your encription passphrase");

   passphraseField.setId("pwdField");
   passphrase2Field.setId("pwdField");

   passphraseField.setMinWidth(400);            
   passphrase2Field.setMinWidth(400);

   TypingHandler typeHandler = new TypingHandler();
   passphrase2Field.addEventHandler(KeyEvent.KEY_RELEASED, typeHandler);
   passphraseField.addEventHandler(KeyEvent.KEY_RELEASED, typeHandler);


   grid.add(infoLabel, 0, 0);
   grid.add(passphraseField, 0, 1);      
   grid.add(passphrase2Field, 0, 2);    

   return grid;

}
项目:Ultrastructure    文件:PasswordDialog.java   
public PasswordDialog() {
    setTitle("HandiNAVI Login");
    setHeaderText("Enter your password.");

    ButtonType passwordButtonType = new ButtonType("Login",
                                                   ButtonData.OK_DONE);
    getDialogPane().getButtonTypes()
                   .addAll(passwordButtonType, ButtonType.CANCEL);

    passwordField = new PasswordField();
    passwordField.setPromptText("Password");

    HBox hBox = new HBox();
    hBox.getChildren()
        .add(passwordField);
    hBox.setPadding(new Insets(20));

    HBox.setHgrow(passwordField, Priority.ALWAYS);

    getDialogPane().setContent(hBox);

    Platform.runLater(() -> passwordField.requestFocus());

    setResultConverter(dialogButton -> {
        if (dialogButton == passwordButtonType) {
            return passwordField.getText();
        }
        return null;
    });
}
项目:titanium    文件:AddServerDialog.java   
public AddServerDialog() {
    super();
    // Create the custom dialog.
    this.setTitle("Add a server");
    this.setHeaderText("Server informations");


    // Set the button types.
    ButtonType addButtonType = new ButtonType("Add server", ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(addButtonType, 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 serverName = new TextField();
    TextField address = new TextField();
    TextField port = new TextField();
    PasswordField password = new PasswordField();


    grid.add(new Label("Server name"), 0, 0);
    grid.add(serverName, 1, 0);
    grid.add(new Label("Address"), 0, 1);
    grid.add(address, 1, 1);
    grid.add(new Label("Port"), 0, 2);
    grid.add(port, 1, 2);
    grid.add(new Label("Password"), 0, 3);
    grid.add(password, 1, 3);


    port.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                port.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });

    Node addButton = this.getDialogPane().lookupButton(addButtonType);



    // Verify required inputs
    // TODO not working
    serverName.textProperty().addListener(new RequieredListener(addButton));
    address.textProperty().addListener(new RequieredListener(addButton));
    port.textProperty().addListener(new RequieredListener(addButton));
    password.textProperty().addListener(new RequieredListener(addButton));


    this.getDialogPane().setContent(grid);

    // Convert the result to a username-password-pair when the login button is clicked.
    this.setResultConverter(dialogButton -> {
        try {
            if (dialogButton == addButtonType) {
                return new LocalServer(serverName.getText(), address.getText(), Integer.parseInt(port.getText()), password.getText());
            }
        } catch (NumberFormatException e) {
            return null;
        }
        return null;
    });

}
项目:titanium    文件:EditServerDialog.java   
public EditServerDialog(LocalServer server) {
    super();
    // Create the custom dialog.
    this.setTitle("Edit server");
    this.setHeaderText("Server informations");


    // Set the button types.
    ButtonType addButtonType = new ButtonType("Edit server", ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(addButtonType, 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));

    System.out.println("server : " + server);
    TextField serverName = new TextField(server.getName());
    TextField address = new TextField(server.getAddress());
    TextField port = new TextField(server.getPort() + "");
    PasswordField password = new PasswordField();
    password.setText(server.getPassword());


    grid.add(new Label("Server name"), 0, 0);
    grid.add(serverName, 1, 0);
    grid.add(new Label("Address"), 0, 1);
    grid.add(address, 1, 1);
    grid.add(new Label("Port"), 0, 2);
    grid.add(port, 1, 2);
    grid.add(new Label("Password"), 0, 3);
    grid.add(password, 1, 3);


    port.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                port.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });

    Node addButton = this.getDialogPane().lookupButton(addButtonType);



    // Verify required inputs
    // TODO not working
    serverName.textProperty().addListener(new RequieredListener(addButton));
    address.textProperty().addListener(new RequieredListener(addButton));
    port.textProperty().addListener(new RequieredListener(addButton));
    password.textProperty().addListener(new RequieredListener(addButton));


    this.getDialogPane().setContent(grid);

    this.setResultConverter(dialogButton -> {
        try {
            if (dialogButton == addButtonType) {
                return new LocalServer(serverName.getText(), address.getText(), Integer.parseInt(port.getText()), password.getText());
            }
        } catch (NumberFormatException e) {
            return null;
        }
        return null;
    });

}
项目:amelia    文件:MainApp.java   
private void openLoginDialog(WindowEvent evt) {
    // Create the custom dialog.
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Closing app...");
        dialog.setHeaderText("Root Credentials Needed");

        ButtonType loginButtonType = new ButtonType("Exit", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

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

        TextField username = new TextField();
        username.setPromptText("Username");
        PasswordField password = new PasswordField();
        password.setPromptText("Password");

        grid.add(new Label("Username:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Password:"), 0, 1);
        grid.add(password, 1, 1);
        dialog.getDialogPane().getStylesheets().add("/styles/Styles.css");
        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

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

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(() -> username.requestFocus());

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }else{
                return new Pair<>("","");
            }
        });

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

        result.ifPresent(usernamePassword -> {
            if(Hasher.sha(usernamePassword.getValue()).equals(">:��ܰb-���ᦦ�sض5�Z��kxK") && usernamePassword.getKey().equals("root")){
                System.exit(0);
            }else{
                evt.consume();
            }
        });
}
项目:NoMoreOversleeps    文件:JavaFxHelper.java   
public static PasswordField createPasswordField(String promptText)
{
    PasswordField field = new PasswordField();
    field.setPromptText(promptText);
    return field;
}
项目:CyberTigerScoreboard    文件:PasswordDialog.java   
public PasswordField getPasswordField() {
  return passwordField;
}
项目:gatepass    文件:ChangePassword.java   
public void showChangedPassword()
{
    changepass= new Stage();
    changepass.setTitle("Change Password");
    changepass.initModality(Modality.APPLICATION_MODAL);
    changepass.getIcons().add(new Image("/pic/slogo.png"));
    lname= new Label("Username");
    txtusername= new TextField();
    txtusername.setText(MainWindow.lname.getText());
    txtusername.setEditable(false);
    txtusername.setMaxSize(250, 100);

    lnew= new Label("New Password");
    newpass= new PasswordField();
    newpass.setPromptText("new password");
    newpass.setMaxSize(250, 100);

    btnsave= new Button("Save");
    btnsave.setOnAction(e ->{
        setChangePass();
    });
    btnclose= new Button("Close");
    btnclose.setOnAction(e ->{
        changepass.close();
    });

    VBox lay1= new VBox(23);
    lay1.getChildren().addAll(lname, lnew);
    VBox lay2= new VBox(10);
    lay2.getChildren().addAll(txtusername, newpass);

    HBox laydet= new HBox(10);
    laydet.setAlignment(Pos.CENTER);
    laydet.setPadding(new Insets(10,10,10,10));
    laydet.setBorder(new Border(new BorderStroke(Color.LIGHTGREY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
    laydet.getChildren().addAll(lay1, lay2);

    HBox laybtn= new HBox(10);
    laybtn.setAlignment(Pos.CENTER_RIGHT);
    laybtn.getChildren().addAll(btnsave, btnclose);

    VBox layall= new VBox(10);
    layall.setPadding(new Insets(10,10,10,10));
    layall.getChildren().addAll(laydet, laybtn);
    layall.setStyle("-fx-background-color: linear-gradient(#E4E9A9, #9CD777);");
    scene1= new Scene(layall);
    scene1.getStylesheets().add(ChangePassword.class.getResource("users.css").toExternalForm());
    changepass.setScene(scene1);
    changepass.setResizable(false);
    changepass.show();
}