當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。