Browse Source

added a second password text field so the user has to input the same password twice

remotes/origin/feature/client/make-input-field-buttons-interactive
Richard Schmidt 11 months ago
parent
commit
f10b645757
  1. 29
      src/main/java/SignUpGUI.java
  2. 6
      user.json

29
src/main/java/SignUpGUI.java

@ -4,12 +4,12 @@ import java.awt.event.ActionListener;
import java.util.UUID;
public class SignUpGUI extends JFrame implements ActionListener {
private JTextField usernameField, passwordField, birthdayField;
private JTextField usernameField, passwordField, confirmPasswordField, birthdayField;
private JButton signUpButton;
public SignUpGUI() {
setTitle("Sign Up");
setSize(300, 200);
setSize(300, 250);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(null);
@ -20,7 +20,7 @@ public class SignUpGUI extends JFrame implements ActionListener {
usernameField = new JTextField();
usernameField.setBounds(100, 20, 160, 25);
add(usernameField);
JLabel passwordLabel = new JLabel("Password:");
passwordLabel.setBounds(20, 50, 80, 25);
add(passwordLabel);
@ -28,17 +28,25 @@ public class SignUpGUI extends JFrame implements ActionListener {
passwordField = new JPasswordField();
passwordField.setBounds(100, 50, 160, 25);
add(passwordField);
JLabel confirmPasswordLabel = new JLabel("Confirm Password:");
confirmPasswordLabel.setBounds(20, 80, 120, 25);
add(confirmPasswordLabel);
confirmPasswordField = new JPasswordField();
confirmPasswordField.setBounds(140, 80, 120, 25);
add(confirmPasswordField);
JLabel birthdayLabel = new JLabel("Birthday:");
birthdayLabel.setBounds(20, 80, 80, 25);
birthdayLabel.setBounds(20, 110, 80, 25);
add(birthdayLabel);
birthdayField = new JTextField();
birthdayField.setBounds(100, 80, 160, 25);
birthdayField.setBounds(100, 110, 160, 25);
add(birthdayField);
signUpButton = new JButton("Sign Up");
signUpButton.setBounds(100, 120, 100, 25);
signUpButton.setBounds(100, 150, 100, 25);
signUpButton.addActionListener(this);
add(signUpButton);
@ -49,8 +57,13 @@ public class SignUpGUI extends JFrame implements ActionListener {
if (e.getSource() == signUpButton) {
String username = usernameField.getText();
String password = passwordField.getText();
String confirmPassword = confirmPasswordField.getText();
String birthday = birthdayField.getText();
if (!password.equals(confirmPassword)) {
JOptionPane.showMessageDialog(this, "Passwords do not match!", "Sign Up Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
UUID randomUUID = UUID.randomUUID();
CreateUser user = CreateUser.createUser(randomUUID.toString(), username, password, birthday);

6
user.json

@ -22,5 +22,11 @@
"userName": "asd",
"password": "asdasdasd",
"birthday": "asd"
},
{
"id": "1e035bce-37b5-4f1e-894e-8136b8021c4d",
"userName": "asd",
"password": "123456",
"birthday": "1234"
}
]
Loading…
Cancel
Save