本文整理汇总了Java中javafx.scene.control.PasswordField.setPromptText方法的典型用法代码示例。如果您正苦于以下问题:Java PasswordField.setPromptText方法的具体用法?Java PasswordField.setPromptText怎么用?Java PasswordField.setPromptText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.PasswordField
的用法示例。
在下文中一共展示了PasswordField.setPromptText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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 "";
});
}
示例4: loginInput
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
private HBox loginInput () {
HBox input = new HBox(TEXT_SPACING);
myLoginUsername = new TextField();
myLoginUsername.setPromptText(USR);
myLoginPassword = new PasswordField();
myLoginPassword.setPromptText(PS);
input.getChildren().addAll(myLoginUsername, myLoginPassword);
input.setAlignment(Pos.CENTER);
input.setPrefHeight(HEIGHT / 2);
return input;
}
示例5: userInput
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
private HBox userInput () {
HBox input = new HBox(TEXT_SPACING);
myMakeUsername = new TextField();
myMakeUsername.setPromptText(USR);
myMakeDisplayname = new TextField();
myMakeDisplayname.setPromptText("Display Name");
myMakePassword = new PasswordField();
myMakePassword.setPromptText(PS);
input.getChildren().addAll(myMakeUsername, myMakeDisplayname, myMakePassword);
input.setAlignment(Pos.CENTER);
input.setPrefHeight(HEIGHT / 2);
return input;
}
示例6: constructContainer
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("registerviewbg");
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
Controls = new HBox(50);
Controls.setAlignment(Pos.CENTER);
Controls.setPadding(new Insets(20));
txtName = new TextField();
txtName.setPromptText("Username");
pwPassword = new PasswordField();
pwPassword.setPromptText("Passwort");
pwToCheck = new PasswordField();
pwToCheck.setPromptText("Passwort wiederholen");
txtMail = new TextField();
txtMail.setPromptText("E-Mail");
reg = new AppButton("Registrieren");
home = new HomeButton(getFXController());
AllFields.getChildren().addAll(txtName, pwPassword, pwToCheck, txtMail, reg);
Controls.getChildren().addAll(home);
bp.setBottom(Controls);
bp.setCenter(AllFields);
return bp;
}
示例7: addGridPane
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
private Node addGridPane() {
//see http://docs.oracle.com/javafx/2/ui_controls/editor.htm
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
infoLabel = new Label("Insert a passphrase to encrypt your data and protect the application. \n"
+ " Use your fantasy but don't forget it, \n"
+ " you will need it to open the application.\n "
+ " Passphrase must contain at least "+Settings.MIN_PASS_LENGTH+" characters.");
passphraseField = new PasswordField(); passphraseField.setPromptText("Insert your encription passphrase");
passphrase2Field = new PasswordField(); passphrase2Field.setPromptText("Confirm your encription passphrase");
passphraseField.setId("pwdField");
passphrase2Field.setId("pwdField");
passphraseField.setMinWidth(400);
passphrase2Field.setMinWidth(400);
TypingHandler typeHandler = new TypingHandler();
passphrase2Field.addEventHandler(KeyEvent.KEY_RELEASED, typeHandler);
passphraseField.addEventHandler(KeyEvent.KEY_RELEASED, typeHandler);
grid.add(infoLabel, 0, 0);
grid.add(passphraseField, 0, 1);
grid.add(passphrase2Field, 0, 2);
return grid;
}
示例8: PasswordDialog
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
public PasswordDialog() {
setTitle("HandiNAVI Login");
setHeaderText("Enter your password.");
ButtonType passwordButtonType = new ButtonType("Login",
ButtonData.OK_DONE);
getDialogPane().getButtonTypes()
.addAll(passwordButtonType, ButtonType.CANCEL);
passwordField = new PasswordField();
passwordField.setPromptText("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 null;
});
}
示例9: constructContainer
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
Errorbox = new HBox(50);
Errorbox.setAlignment(Pos.CENTER);
Errorbox.setPadding(new Insets(20));
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
Controls = new HBox(50);
Controls.setAlignment(Pos.CENTER);
Controls.setPadding(new Insets(20));
txtName = new TextField();
txtName.setPromptText("Username");
pwPassword = new PasswordField();
pwPassword.setPromptText("Passwort");
;
home = new HomeButton(getFXController());
reg = new AppButton("Noch kein Profil?");
log = new AppButton("Login");
errorText = new Label("");
Errorbox.getChildren().addAll(errorText);
Controls.getChildren().addAll(home, reg);
AllFields.getChildren().addAll(txtName, pwPassword, log);
bp.setTop(Errorbox);
bp.setCenter(AllFields);
bp.setBottom(Controls);
reg.setOnAction(e -> getFXController().showView("registerview"));
log.setOnAction(e ->
{
// So that you can always check again who was logged in last,
// but if user logged in, it should be set as ""
Globals.lastRegisteredUser = "";
String name = txtName.getText();
String password = pwPassword.getText();
// So that entries don't exist after leaving the view
txtName.clear();
pwPassword.clear();
if (name.equals("[email protected]") && BCrypt.checkpw(password, "$2a$12$8hcwdnkJ7uO3FvDEG/1fv.vaSNI/FfZqEzfUZFUYRUHLzRjkV/Z5.")/*plaintext-password: "gibb"*/)
{
Globals.username = name;
getFXController().showView("managementselectionview");
} else
{
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Fehler 0x0001");
alert.setHeaderText("Login-Daten inkorrekt.");
alert.setContentText(
"Benutzername und Passwort stimmen nicht �berein oder existieren nicht.\nStellen Sie sicher, dass Ihre Eingaben korrekt sind.");
pwPassword.clear();
txtName.clear();
alert.showAndWait();
}
});
return bp;
}
示例10: openLoginDialog
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
private void openLoginDialog(WindowEvent evt) {
// Create the custom dialog.
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Closing app...");
dialog.setHeaderText("Root Credentials Needed");
ButtonType loginButtonType = new ButtonType("Exit", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
dialog.getDialogPane().getStylesheets().add("/styles/Styles.css");
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(() -> username.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
}else{
return new Pair<>("","");
}
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
if(Hasher.sha(usernamePassword.getValue()).equals(">:��ܰb-���ᦦ�sض5�Z��kxK") && usernamePassword.getKey().equals("root")){
System.exit(0);
}else{
evt.consume();
}
});
}
示例11: createPasswordField
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
public static PasswordField createPasswordField(String promptText)
{
PasswordField field = new PasswordField();
field.setPromptText(promptText);
return field;
}
示例12: showChangedPassword
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
public void showChangedPassword()
{
changepass= new Stage();
changepass.setTitle("Change Password");
changepass.initModality(Modality.APPLICATION_MODAL);
changepass.getIcons().add(new Image("/pic/slogo.png"));
lname= new Label("Username");
txtusername= new TextField();
txtusername.setText(MainWindow.lname.getText());
txtusername.setEditable(false);
txtusername.setMaxSize(250, 100);
lnew= new Label("New Password");
newpass= new PasswordField();
newpass.setPromptText("new password");
newpass.setMaxSize(250, 100);
btnsave= new Button("Save");
btnsave.setOnAction(e ->{
setChangePass();
});
btnclose= new Button("Close");
btnclose.setOnAction(e ->{
changepass.close();
});
VBox lay1= new VBox(23);
lay1.getChildren().addAll(lname, lnew);
VBox lay2= new VBox(10);
lay2.getChildren().addAll(txtusername, newpass);
HBox laydet= new HBox(10);
laydet.setAlignment(Pos.CENTER);
laydet.setPadding(new Insets(10,10,10,10));
laydet.setBorder(new Border(new BorderStroke(Color.LIGHTGREY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
laydet.getChildren().addAll(lay1, lay2);
HBox laybtn= new HBox(10);
laybtn.setAlignment(Pos.CENTER_RIGHT);
laybtn.getChildren().addAll(btnsave, btnclose);
VBox layall= new VBox(10);
layall.setPadding(new Insets(10,10,10,10));
layall.getChildren().addAll(laydet, laybtn);
layall.setStyle("-fx-background-color: linear-gradient(#E4E9A9, #9CD777);");
scene1= new Scene(layall);
scene1.getStylesheets().add(ChangePassword.class.getResource("users.css").toExternalForm());
changepass.setScene(scene1);
changepass.setResizable(false);
changepass.show();
}
示例13: showLoginDialog
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
/**
* login Dialog 로그인 처리 다이얼로그
*
* @param consumer
* @return
*/
public static <T> Optional<Pair<String, String>> showLoginDialog(Consumer<? super Pair<String, String>> consumer) {
// Create the custom dialog.
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Login Dialog");
dialog.setHeaderText("Look, a Custom Login Dialog");
dialog.setGraphic(new ImageView(new Image("file:resources/images/login.png")));
// Set the button types.
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
ButtonType localButtonType = new ButtonType("Local", ButtonData.APPLY);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, localButtonType, 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));
TextField username = new TextField();
username.setPromptText("Username");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
// Enable/Disable login button depending on whether a username was
// entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(() -> username.requestFocus());
// Convert the result to a username-password-pair when the login button
// is clicked.
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
} else if (dialogButton == localButtonType) {
return new Pair<>(MEMO_LOCAL_USER, "");
}
return null;
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(consumer);
return result;
}
示例14: constructContainer
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
Errorbox = new HBox(50);
Errorbox.setAlignment(Pos.CENTER);
Errorbox.setPadding(new Insets(20));
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
Controls = new HBox(50);
Controls.setAlignment(Pos.CENTER);
Controls.setPadding(new Insets(20));
txtName = new TextField();
txtName.setPromptText("Username");
pwPassword = new PasswordField();
pwPassword.setPromptText("Passwort");;
home = new HomeButton(getFXController());
reg = new AppButton("Noch kein Profil?");
log = new AppButton("Login");
errorText = new Label("");
Errorbox.getChildren().addAll(errorText);
Controls.getChildren().addAll(home, reg);
AllFields.getChildren().addAll(txtName, pwPassword, log);
bp.setTop(Errorbox);
bp.setCenter(AllFields);
bp.setBottom(Controls);
reg.setOnAction(e -> getFXController().showView("registerview"));
return bp;
}
示例15: collectIpCamInfo
import javafx.scene.control.PasswordField; //导入方法依赖的package包/类
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();
}