List of usage examples for javafx.scene.control PasswordField setFont
public final void setFont(Font value)
From source file:User.java
private HBox drawRow2() { PasswordField passwordField = new PasswordField(); passwordField.setFont(Font.font("SanSerif", 20)); passwordField.setPromptText("Password"); passwordField.setStyle(//from w w w .ja va2 s.c o m "-fx-text-fill:black; " + "-fx-prompt-text-fill:gray; " + "-fx-highlight-text-fill:black; " + "-fx-highlight-fill: gray; " + "-fx-background-color: rgba(255, 255, 255, .80); "); passwordField.prefWidthProperty().bind(primaryStage.widthProperty().subtract(55)); user.passwordProperty().bind(passwordField.textProperty()); // error icon SVGPath deniedIcon = new SVGPath(); deniedIcon.setFill(Color.rgb(255, 0, 0, .9)); deniedIcon.setStroke(Color.WHITE);// deniedIcon.setContent("M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 " + "16.447,13.08710.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10" + ".946,24.248 16.447,18.746 21.948,24.248z"); deniedIcon.setVisible(false); SVGPath grantedIcon = new SVGPath(); grantedIcon.setFill(Color.rgb(0, 255, 0, .9)); grantedIcon.setStroke(Color.WHITE);// grantedIcon.setContent( "M2.379,14.729 5.208,11.899 12.958,19.648 25.877," + "6.733 28.707,9.56112.958,25.308z"); grantedIcon.setVisible(false); // StackPane accessIndicator = new StackPane(); accessIndicator.getChildren().addAll(deniedIcon, grantedIcon); accessIndicator.setAlignment(Pos.CENTER_RIGHT); grantedIcon.visibleProperty().bind(GRANTED_ACCESS); // user hits the enter key passwordField.setOnAction(actionEvent -> { if (GRANTED_ACCESS.get()) { System.out.printf("User %s is granted access.\n", user.getUserName()); System.out.printf("User %s entered the password: %s\n", user.getUserName(), user.getPassword()); Platform.exit(); } else { deniedIcon.setVisible(true); } ATTEMPTS.set(ATTEMPTS.add(1).get()); System.out.println("Attempts: " + ATTEMPTS.get()); }); // listener when the user types into the password field passwordField.textProperty().addListener((obs, ov, nv) -> { boolean granted = passwordField.getText().equals(MY_PASS); GRANTED_ACCESS.set(granted); if (granted) { deniedIcon.setVisible(false); } }); // listener on number of attempts ATTEMPTS.addListener((obs, ov, nv) -> { if (MAX_ATTEMPTS == nv.intValue()) { // failed attempts System.out.printf("User %s is denied access.\n", user.getUserName()); Platform.exit(); } }); // second row HBox row2 = new HBox(3); row2.getChildren().addAll(passwordField, accessIndicator); return row2; }