|
|
@ -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); |
|
|
|