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. 23
      src/main/java/SignUpGUI.java
  2. 6
      user.json

23
src/main/java/SignUpGUI.java

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

6
user.json

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