From bea41ebeb427e9e6ef8d86a2dced5df4159b7477 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Sat, 22 Jan 2022 18:00:54 +0100 Subject: [PATCH] gameexplorer_gui: added actionListener for exit button --- src/main/java/de/tims/gameexplorer/GameExplorer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/de/tims/gameexplorer/GameExplorer.java b/src/main/java/de/tims/gameexplorer/GameExplorer.java index f78f205..cba4803 100644 --- a/src/main/java/de/tims/gameexplorer/GameExplorer.java +++ b/src/main/java/de/tims/gameexplorer/GameExplorer.java @@ -97,6 +97,7 @@ public class GameExplorer { logoutBtn.addActionListener(new LogoutAction()); exitBtn = new JButton("Exit"); exitBtn.setPreferredSize(smallBtnSize); + exitBtn.addActionListener(new ExitAction()); border1 = new JPanel(); border1.setOpaque(false); @@ -338,6 +339,15 @@ public class GameExplorer { } } + private class ExitAction implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + manager.savePlayers(PLAYER_FILE); + + System.exit(0); + } + } + private class BackAction implements ActionListener { @Override public void actionPerformed(ActionEvent e) {