本文整理匯總了Java中javafx.scene.control.PasswordField.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java PasswordField.setText方法的具體用法?Java PasswordField.setText怎麽用?Java PasswordField.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.PasswordField
的用法示例。
在下文中一共展示了PasswordField.setText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
}
示例3: createObject
import javafx.scene.control.PasswordField; //導入方法依賴的package包/類
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;
}
示例4: shouldClickOkButton
import javafx.scene.control.PasswordField; //導入方法依賴的package包/類
@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();
}
示例5: PasswordDialog
import javafx.scene.control.PasswordField; //導入方法依賴的package包/類
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);
}
示例6: EditServerDialog
import javafx.scene.control.PasswordField; //導入方法依賴的package包/類
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;
});
}