Commit 999f0792 authored by 9831111's avatar 9831111 🙂

Add initRemindMe method.

parent ae240047
......@@ -29,11 +29,12 @@ public class LoginFrame extends JFrame {
setBounds(700, 250, 320, 515);
initLoginFrame();
// initRemindMe();
initRemindMe();
// initInformationPanel();
setVisible(true);
}
public void initLoginFrame() {
tankPhoto = new ImageIcon("gifFiles/gif.gif");
......@@ -65,6 +66,24 @@ public class LoginFrame extends JFrame {
}
public void initRemindMe() {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
String account;
while (scanner.hasNextLine()) {
account = scanner.nextLine() + "\n";
String[] strings = account.split(" ");
if (account.contains("true")) {
remindMe.setSelected(true);
userName.setText(strings[0]);
passwordField.setText(strings[1]);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void signUpUser(File accounts) {
try (FileWriter fileWriter = new FileWriter(accounts, true)) {
fileWriter.write(userName.getText() + " " + passwordField.getText() + " " + remindMe.isSelected() + " 0 0 0 0 0 " + "\n");
......@@ -77,6 +96,7 @@ public class LoginFrame extends JFrame {
}
}
public void signInUser() {
File accounts = new File("Accounts.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
......@@ -103,12 +123,14 @@ public class LoginFrame extends JFrame {
}
}
class SignInAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
signInUser();
}
}
class SignUpAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
......@@ -132,5 +154,4 @@ public class LoginFrame extends JFrame {
}
}
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