本文整理匯總了Java中javafx.scene.control.PasswordField類的典型用法代碼示例。如果您正苦於以下問題:Java PasswordField類的具體用法?Java PasswordField怎麽用?Java PasswordField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PasswordField類屬於javafx.scene.control包,在下文中一共展示了PasswordField類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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();
}
示例2: initData
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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();
});
}
示例3: confirmPassword
import javafx.scene.control.PasswordField; //導入依賴的package包/類
/**
* 確認兩次密碼是否一致.
* @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;
}
);
}
示例4: PasswordPane
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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);
}
示例5: isPasswordField
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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());
}
示例6: shouldClickOkButtonWhenProxyPasswordIsInvalid
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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();
}
示例7: initControls
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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);
}
示例8: CombinedPasswordValidator
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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);
}
};
}
示例9: CombinedPinValidator
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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);
}
};
}
示例10: marathon_select
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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());
}
};
}
示例11: getText
import javafx.scene.control.PasswordField; //導入依賴的package包/類
@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());
}
示例12: PasswordFieldSample
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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);
}
示例13: display
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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();
}
示例14: PasswordDialog
import javafx.scene.control.PasswordField; //導入依賴的package包/類
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 "";
});
}
示例15: LoginComponent
import javafx.scene.control.PasswordField; //導入依賴的package包/類
public LoginComponent(BorderPane p) {
GridPane g = new GridPane();
{
g.add(new Label("Username"), 0, 0);
username = new TextField();
g.add(username, 1, 0);
}
{
g.add(new Label("Password"), 0, 1);
password = new PasswordField();
g.add(password, 1, 1);
}
Button button = new Button("Login");
button.setOnAction(e -> {
if( username.getText().equals("[email protected]") ) {
if( password.getText().equals("test") ) {
status = Status.ok();
} else {
status = Status.status(Status.State.ERROR, 2, "Invalid password for '"+username.getText()+"'", null);
}
} else {
status = Status.status(Status.State.ERROR, 1, "Unknown username", null);
}
});
g.add(button, 1, 2);
g.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
g.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
p.setCenter(g);
}