Create a program that utilizes Javas new Graphic User Interf

Create a program that utilizes Java\'s new Graphic User Interface library FX. The goal of this project is to demonstrate basic FX GUI programming. The program needs to accept a password from the user and determine if it meets the specifications listed below. The user interface should consist of a TextField for the user to enter their password, a Button that triggers validation of the password and finally a Label that appears after the button is pressed showing either success or listing the tests the password failed on. The Label should be initially hidden. The password needs to have: at least 1 lowercase letter at least 1 uppercase letter at least 1 digit (0-9) at least 1 of the following special characters: !@$#%? Note: For credit this project needs to use the FX libraries

Solution

final Label message = new Label(\"\");

VBox vbhdhd = new VBox();
vbhdhd.setPadding(new Insets(10, 0, 0, 10));
vbhdhd.setSpacing(10);
HBox hb = new HBox();
hb.setSpacing(10);
hb.setAlignment(Pos.CENTER_LEFT);

Label lbll = new Label(\"Password\");
final PasswordField pbbb = new PasswordField();

pbbb.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
  
if (!pbbb.getText().matches(\"[1-5]\\\\.[0-9]|6\\\\.0\")) {
message.setText(\"Password is incorrect!\");
message.setTextFill(Color.rgb(210, 39, 30));
} else {
message.setText(\"Password has been confirmed\");
message.setTextFill(Color.rgb(21, 117, 84));
}
pbbb.clear();
}
});

hb.getChildren().addAll(lbll, pbbb);
vbhdhd.getChildren().addAll(hb, message);

Create a program that utilizes Java\'s new Graphic User Interface library FX. The goal of this project is to demonstrate basic FX GUI programming. The program n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site