|
@ -5,6 +5,7 @@ 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, birthdayField; |
|
|
|
|
|
private JButton signUpButton; |
|
|
|
|
|
|
|
|
public SignUpGUI() { |
|
|
public SignUpGUI() { |
|
|
setTitle("Sign Up"); |
|
|
setTitle("Sign Up"); |
|
@ -36,10 +37,29 @@ public class SignUpGUI extends JFrame implements ActionListener { |
|
|
birthdayField.setBounds(100, 80, 160, 25); |
|
|
birthdayField.setBounds(100, 80, 160, 25); |
|
|
add(birthdayField); |
|
|
add(birthdayField); |
|
|
|
|
|
|
|
|
|
|
|
signUpButton = new JButton("Sign Up"); |
|
|
|
|
|
signUpButton.setBounds(100, 120, 100, 25); |
|
|
|
|
|
signUpButton.addActionListener(this); |
|
|
|
|
|
add(signUpButton); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
if (e.getSource() == signUpButton) { |
|
|
|
|
|
String username = usernameField.getText(); |
|
|
|
|
|
String password = passwordField.getText(); |
|
|
|
|
|
String birthday = birthdayField.getText(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
UUID randomUUID = UUID.randomUUID(); |
|
|
|
|
|
CreateUser user = CreateUser.createUser(randomUUID.toString(), username, password, birthday); |
|
|
|
|
|
user.saveToJsonFile("user.json"); |
|
|
|
|
|
JOptionPane.showMessageDialog(this, "User signed up successfully!"); |
|
|
|
|
|
} catch (IllegalArgumentException ex) { |
|
|
|
|
|
JOptionPane.showMessageDialog(this, "Error: " + ex.getMessage(), "Sign Up Error", JOptionPane.ERROR_MESSAGE); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|