当前位置: 首页>>代码示例>>Java>>正文


Java PasswordField.setText方法代码示例

本文整理汇总了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();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:PasswordFiledSample.java

示例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();
}
 
开发者ID:mpcontracting,项目名称:rpmjukebox,代码行数:20,代码来源:SettingsControllerTest.java

示例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;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:9,代码来源:PasswordFieldApp.java

示例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();
}
 
开发者ID:mpcontracting,项目名称:rpmjukebox,代码行数:30,代码来源:SettingsControllerTest.java

示例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);
}
 
开发者ID:NoticEditorTeam,项目名称:NoticEditor,代码行数:12,代码来源:PasswordDialog.java

示例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;
	});

}
 
开发者ID:ScreachFr,项目名称:titanium,代码行数:71,代码来源:EditServerDialog.java


注:本文中的javafx.scene.control.PasswordField.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。