javafx.scene.control.PasswordField Java Examples

The following examples show how to use javafx.scene.control.PasswordField. 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: CombinedPinValidator.java    From PeerWasp with MIT License 6 votes vote down vote up
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);
		}
	};
}
 
Example #2
Source File: CombinedPasswordValidator.java    From PeerWasp with MIT License 6 votes vote down vote up
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);
		}
	};
}
 
Example #3
Source File: ConnectController.java    From MythRedisClient with Apache License 2.0 6 votes vote down vote up
/**
 * 确认两次密码是否一致.
 * @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;
        }
    );
}
 
Example #4
Source File: JavaFXPasswordFieldElementTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@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());
        }
    };
}
 
Example #5
Source File: JavaFXPasswordFieldElementTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #6
Source File: LoginProvider.java    From iliasDownloaderTool with GNU General Public License v2.0 5 votes vote down vote up
public LoginProvider(Dashboard dashboard, TextField usernameField, PasswordField passwordField,
		RadioButton savePwd) {
	this.dashboard = dashboard;
	this.usernameField = usernameField;
	this.passwordField = passwordField;
	this.savePwd = savePwd;
}
 
Example #7
Source File: DualPasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
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;
    });
}
 
Example #8
Source File: PasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
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;
    });
}
 
Example #9
Source File: PasswordFieldSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: PasswordFiledSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #11
Source File: PasswordParameter.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PasswordField createEditingComponent() {
  PasswordField passwordComponent = new PasswordField();
  passwordComponent.setPrefColumnCount(inputsize);
  // passwordComponent.setBorder(BorderFactory.createCompoundBorder(passwordComponent.getBorder(),
  // BorderFactory.createEmptyBorder(0, 4, 0, 0)));
  return passwordComponent;
}
 
Example #12
Source File: JavaFXPasswordFieldElementTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@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());
        }
    };
}
 
Example #13
Source File: SettingFragment.java    From Notebook with Apache License 2.0 5 votes vote down vote up
@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();
	});


}
 
Example #14
Source File: ViewerSkin.java    From DashboardFx with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected String maskText(String txt) {
    if (getSkinnable() instanceof PasswordField && shouldMaskText) {
        int n = txt.length();
        StringBuilder passwordBuilder = new StringBuilder(n);
        for (int i = 0; i < n; i++) {
            passwordBuilder.append(BULLET);
        }
        return passwordBuilder.toString();
    } else {
        return txt;
    }
}
 
Example #15
Source File: DemoLoginPane.java    From FxDock with Apache License 2.0 4 votes vote down vote up
public DemoLoginPane()
{
	super(DemoGenerator.LOGIN);
	setTitle("CPane Demo // Login Form");

	String info = "This demonstrates table layout capabilities of CPane component.  CPane is easier to use than GridPane because one does not have to set so many constraints on the inidividual nodes, and you also have border layout capability as well.";

	infoField = new TextFlow(new Text(info));

	userNameField = new TextField();

	passwordField = new PasswordField();

	loginButton = new FxButton("Login");
	loginButton.setMinWidth(100);

	CPane p = new CPane();
	p.setGaps(10, 7);
	p.setPadding(10);
	p.addColumns
	(
		10,
		CPane.PREF,
		CPane.FILL,
		CPane.PREF,
		10
	);
	p.addRows
	(
		10,
		CPane.PREF,
		CPane.PREF,
		CPane.PREF,
		CPane.PREF,
		CPane.FILL,
		10
	);
	int r = 1;
	p.add(1, r, 3, 1, infoField); 
	r++;
	p.add(1, r, FX.label("User name:", TextAlignment.RIGHT));
	p.add(2, r, 2, 1, userNameField);
	r++;
	p.add(1, r, FX.label("Password:", TextAlignment.RIGHT));
	p.add(2, r, 2, 1, passwordField);
	r++;
	p.add(3, r, loginButton);
	
	setContent(p);
}
 
Example #16
Source File: JFXPasswordField.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JFXPasswordField(JFXContainer<? extends Region> parent) {
	super(new PasswordField(), parent);
}
 
Example #17
Source File: PreferencesController.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
private void collectIpCamInfo() {
	final Stage ipcamStage = new Stage();
	final GridPane ipcamPane = new GridPane();

	final ColumnConstraints cc = new ColumnConstraints(400);
	cc.setHalignment(HPos.CENTER);
	ipcamPane.getColumnConstraints().addAll(new ColumnConstraints(), cc);

	final TextField nameTextField = new TextField();
	ipcamPane.add(new Label("IPCam Name:"), 0, 0);
	ipcamPane.add(nameTextField, 1, 0);

	final TextField userTextField = new TextField();
	userTextField.setPromptText("Optional Username");
	ipcamPane.add(new Label("Username:"), 0, 1);
	ipcamPane.add(userTextField, 1, 1);

	final PasswordField passwordField = new PasswordField();
	passwordField.setPromptText("Optional Password");
	ipcamPane.add(new Label("Password:"), 0, 2);
	ipcamPane.add(passwordField, 1, 2);

	final TextField urlTextField = new TextField("http://");
	ipcamPane.add(new Label("IPCam URL:"), 0, 3);
	ipcamPane.add(urlTextField, 1, 3);

	final Button okButton = new Button("OK");
	okButton.setDefaultButton(true);
	ipcamPane.add(okButton, 1, 4);

	okButton.setOnAction((e) -> {
		if (nameTextField.getText().isEmpty() || urlTextField.getText().isEmpty()) {
			final Alert ipcamInfoAlert = new Alert(AlertType.ERROR);
			ipcamInfoAlert.setTitle("Missing Information");
			ipcamInfoAlert.setHeaderText("Missing Required IPCam Information!");
			ipcamInfoAlert.setResizable(true);
			ipcamInfoAlert.setContentText("Please fill in both the IPCam name and the URL.");
			ipcamInfoAlert.showAndWait();
			return;
		}

		Optional<String> username = Optional.empty();
		Optional<String> password = Optional.empty();

		if (!userTextField.getText().isEmpty() || !passwordField.getText().isEmpty()) {
			username = Optional.of(userTextField.getText());
			password = Optional.of(passwordField.getText());
		}

		final Optional<Camera> cam = config.registerIpCam(nameTextField.getText(), urlTextField.getText(), username,
				password);

		if (cam.isPresent()) {
			CheckableImageListCell.cacheCamera(cam.get(), PreferencesController.this);

			if (!configuredCameras.contains(cam.get())) {
				Platform.runLater(() -> {
					webcamListView.setItems(null);
					cameras.add(cam.get().getName());
					webcamListView.setItems(cameras);
				});
			}
		}

		ipcamStage.close();
	});

	final Scene scene = new Scene(ipcamPane);
	ipcamStage.initOwner(preferencesPane.getScene().getWindow());
	ipcamStage.initModality(Modality.WINDOW_MODAL);
	ipcamStage.setTitle("Register IPCam");
	ipcamStage.setScene(scene);
	ipcamStage.showAndWait();
}
 
Example #18
Source File: LoginDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected Parent content() {
    setTitle(DIALOG_TITLE);
    setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    setStageStyle(StageStyle.UTILITY);

    GridPane grid = new GridPane();
    setupGridPane(grid);

    Label repoLabel = new Label(LABEL_REPO);
    grid.add(repoLabel, 0, 0);

    Label githubLabel = new Label(LABEL_GITHUB);
    grid.add(githubLabel, 1, 0);

    repoOwnerField = new TextField();
    repoOwnerField.setId(IdGenerator.getLoginDialogOwnerFieldId());
    repoOwnerField.setPrefWidth(140);
    grid.add(repoOwnerField, 2, 0);

    Label slash = new Label("/");
    grid.add(slash, 3, 0);

    repoNameField = new TextField();
    repoNameField.setPrefWidth(250);
    grid.add(repoNameField, 4, 0);

    Label usernameLabel = new Label(USERNAME_LABEL);
    grid.add(usernameLabel, 0, 1);

    usernameField = new TextField();
    grid.add(usernameField, 1, 1, 4, 1);

    Label passwordLabel = new Label(PASSWORD_LABEL);
    grid.add(passwordLabel, 0, 2);

    passwordField = new PasswordField();
    grid.add(passwordField, 1, 2, 4, 1);

    repoOwnerField.setOnAction(e -> login());
    repoNameField.setOnAction(e -> login());
    usernameField.setOnAction(e -> login());
    passwordField.setOnAction(e -> login());

    HBox buttons = new HBox(10);
    buttons.setAlignment(Pos.BOTTOM_RIGHT);
    loginButton = new Button(BUTTON_SIGN_IN);
    loginButton.setOnAction(e -> login());
    buttons.getChildren().add(loginButton);
    grid.add(buttons, 4, 3);

    return grid;
}
 
Example #19
Source File: ViewerSkin.java    From DashboardFx with GNU General Public License v3.0 4 votes vote down vote up
public ViewerSkin(PasswordField textField) {
    super(textField);
}
 
Example #20
Source File: SkinAction.java    From DashboardFx with GNU General Public License v3.0 4 votes vote down vote up
PasswordField getPasswordField() {
    return passwordField;
}
 
Example #21
Source File: SkinAction.java    From DashboardFx with GNU General Public License v3.0 4 votes vote down vote up
SkinAction(PasswordField passwordField){
    super(passwordField);
    this.passwordField = passwordField;
    config();
    setupListeners();
}
 
Example #22
Source File: PasswordParameter.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValueToComponent(PasswordField component, String newValue) {
  component.setText(newValue);
}
 
Example #23
Source File: PasswordParameter.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValueFromComponent(PasswordField component) {
  value = component.getText().toString();
}