use of javafx.scene.control.PasswordField in project jphp by jphp-compiler.
the class UXPasswordField method __construct.
@Override
public void __construct(String text) {
__wrappedObject = new PasswordField();
getWrappedObject().setText(text);
}
use of javafx.scene.control.PasswordField in project Gargoyle by callakrsos.
the class DialogUtil method showLoginDialog.
/**
* 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;
}
use of javafx.scene.control.PasswordField in project sandbox by irof.
the class Login method start.
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("JavaFX Welcome");
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Text scenetitle = new Text("Welcome");
scenetitle.setId("welcome-text");
grid.add(scenetitle, 0, 0, 2, 1);
Label userName = new Label("User Name:");
grid.add(userName, 0, 1);
TextField userTextField = new TextField();
grid.add(userTextField, 1, 1);
Label password = new Label("Password:");
grid.add(password, 0, 2);
PasswordField passwordField = new PasswordField();
grid.add(passwordField, 1, 2);
Button button = new Button("Sign in");
HBox hBox = new HBox(10);
hBox.setAlignment(Pos.BOTTOM_RIGHT);
hBox.getChildren().add(button);
grid.add(hBox, 1, 4);
Text actionTarget = new Text();
actionTarget.setId("actiontarget");
grid.add(actionTarget, 1, 6);
button.setOnAction(e -> {
actionTarget.setText("Sign in button pressed");
});
Scene scene = new Scene(grid, 300, 275);
scene.getStylesheets().add(Login.class.getResource("Login.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.control.PasswordField in project jgnash by ccavanaugh.
the class NetworkAuthenticator method getPasswordAuthentication.
@Override
protected PasswordAuthentication getPasswordAuthentication() {
final Preferences auth = Preferences.userRoot().node(NODEHTTP);
final ResourceBundle resources = ResourceUtils.getBundle();
final char[][] pass = { null };
final String[] user = new String[1];
// get the password
if (auth.get(HTTPPASS, null) != null && !auth.get(HTTPPASS, null).isEmpty()) {
pass[0] = auth.get(HTTPPASS, null).toCharArray();
}
// get the user
user[0] = auth.get(HTTPUSER, null);
if (user[0] != null) {
if (user[0].length() <= 0) {
user[0] = null;
}
}
// if either returns null, pop a dialog
if (user[0] == null || pass[0] == null) {
final Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle(resources.getString("Title.HTTPProxy"));
dialog.setHeaderText(resources.getString("Message.EnterNetworkAuth"));
// Set the button types.
final ButtonType loginButtonType = new ButtonType(resources.getString("Button.Ok"), ButtonBar.ButtonData.OK_DONE);
ThemeManager.applyStyleSheets(dialog.getDialogPane());
dialog.getDialogPane().getStyleClass().addAll("dialog");
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
final GridPane grid = new GridPane();
grid.getStyleClass().addAll("form");
final TextField userNameField = new TextField();
final PasswordField passwordField = new PasswordField();
grid.add(new Label(resources.getString("Label.UserName")), 0, 0);
grid.add(userNameField, 1, 0);
grid.add(new Label(resources.getString("Label.Password")), 0, 1);
grid.add(passwordField, 1, 1);
// Enable/Disable login button depending on whether a username was entered.
final Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// bind the button, must not be empty
loginButton.disableProperty().bind(userNameField.textProperty().isEmpty());
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
JavaFXUtils.runLater(userNameField::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(userNameField.getText(), passwordField.getText());
}
return null;
});
final Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
user[0] = usernamePassword.getKey();
pass[0] = usernamePassword.getValue().toCharArray();
});
}
return new PasswordAuthentication(user[0], pass[0] != null ? pass[0] : new char[0]);
}
Aggregations