diff --git a/src/main/java/SignUpGUI.java b/src/main/java/SignUpGUI.java index fdbb160..520adb1 100644 --- a/src/main/java/SignUpGUI.java +++ b/src/main/java/SignUpGUI.java @@ -5,7 +5,8 @@ import java.util.UUID; public class SignUpGUI extends JFrame implements ActionListener { private JTextField usernameField, passwordField, birthdayField; - + private JButton signUpButton; + public SignUpGUI() { setTitle("Sign Up"); setSize(300, 200); @@ -35,11 +36,30 @@ public class SignUpGUI extends JFrame implements ActionListener { birthdayField = new JTextField(); birthdayField.setBounds(100, 80, 160, 25); add(birthdayField); + + signUpButton = new JButton("Sign Up"); + signUpButton.setBounds(100, 120, 100, 25); + signUpButton.addActionListener(this); + add(signUpButton); } @Override 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) { diff --git a/user.json b/user.json index 7040154..e407c0d 100644 --- a/user.json +++ b/user.json @@ -10,5 +10,11 @@ "userName": "asd", "password": "test1234", "birthday": "01.01.2013" + }, + { + "id": "4165bfe6-9851-480f-90e1-8229415fa44e", + "userName": "asdasdasd", + "password": "1231412512", + "birthday": "1111111" } ] \ No newline at end of file