From f24fb69051d6a739b95aa645356b552b4ed6322e Mon Sep 17 00:00:00 2001 From: Richard Schmidt Date: Fri, 9 Feb 2024 21:47:27 +0100 Subject: [PATCH] refactoring: stayLoggedInCheckbox listener in LoginGUI --- src/main/java/LoginGUI.java | 17 +++++++---------- user.json | 3 +-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/LoginGUI.java b/src/main/java/LoginGUI.java index 6731ae7..a05d9ca 100644 --- a/src/main/java/LoginGUI.java +++ b/src/main/java/LoginGUI.java @@ -75,17 +75,14 @@ public class LoginGUI extends JFrame implements ActionListener { passwordField.addKeyListener(new EnterKeyListener()); - stayLoggedInCheckbox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean stayLoggedIn = stayLoggedInCheckbox.isSelected(); - String username = usernameField.getText(); - // Set stayLoggedIn to false if the checkbox is unchecked - if (!stayLoggedInCheckbox.isSelected()) { - stayLoggedIn = false; - } - updateStayLoggedIn(username, stayLoggedIn); + stayLoggedInCheckbox.addActionListener(e -> { + boolean stayLoggedIn = stayLoggedInCheckbox.isSelected(); + String username = usernameField.getText(); + // Set stayLoggedIn to false if the checkbox is unchecked + if (!stayLoggedInCheckbox.isSelected()) { + stayLoggedIn = false; } + updateStayLoggedIn(username, stayLoggedIn); }); } diff --git a/user.json b/user.json index 32960f8..0637a08 100644 --- a/user.json +++ b/user.json @@ -1,2 +1 @@ -[ -] \ No newline at end of file +[] \ No newline at end of file