Commit ae240047 authored by 9831111's avatar 9831111 🙂

Add signUp Action Listener.

parent 35c5300e
......@@ -60,7 +60,7 @@ public class LoginFrame extends JFrame {
add(buttonPanel, BorderLayout.SOUTH);
// signUp.addActionListener(new SignUpAction());
signUp.addActionListener(new SignUpAction());
signIn.addActionListener(new SignInAction());
......@@ -109,6 +109,27 @@ public class LoginFrame extends JFrame {
signInUser();
}
}
class SignUpAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
String account = "";
while (scanner.hasNextLine()) {
account = scanner.nextLine() + "\n";
}
if (account.contains(userName.getText())) {
JFrame userFound = new JFrame();
JOptionPane.showMessageDialog(userFound, "This User already exists ! ", "", JOptionPane.ERROR_MESSAGE);
} else {
signUpUser(accounts);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment