Browse Source

gameexplorer_gui: added actionListener for logout button

gameexplorer_gui
Tobias Krause 3 years ago
committed by Lorenz Hohmann
parent
commit
713f6b19c8
  1. 21
      src/main/java/de/tims/gameexplorer/GameExplorer.java

21
src/main/java/de/tims/gameexplorer/GameExplorer.java

@ -44,7 +44,7 @@ public class GameExplorer {
private Dimension smallBtnSize;
private GridBagConstraints gbc;
private static final String playerFile = "src/main/java/resources/player_data.csv";
private static final String PLAYER_FILE = "src/main/java/resources/player_data.csv";
private enum Game { FLEETSTORM, FOURWINS, TICTACTOE, LEADERBOARD };
private Game actualGame;
@ -94,6 +94,7 @@ public class GameExplorer {
leaderboardBtn.addActionListener(new GameAction());
logoutBtn = new JButton("Logout");
logoutBtn.setPreferredSize(smallBtnSize);
logoutBtn.addActionListener(new LogoutAction());
exitBtn = new JButton("Exit");
exitBtn.setPreferredSize(smallBtnSize);
@ -278,9 +279,10 @@ public class GameExplorer {
if (!userInput.equals("")) {
loginWarning.setText("");
manager.loadPlayers(playerFile);
manager.loadPlayers(PLAYER_FILE);
actualPlayer = manager.selectPlayer(userInput);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.remove(loginPanel);
frame.add(explorerPanel);
frame.revalidate();
@ -321,6 +323,21 @@ public class GameExplorer {
}
}
private class LogoutAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
manager.savePlayers(PLAYER_FILE);
buildLoginPanel();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.remove(explorerPanel);
frame.add(loginPanel);
frame.revalidate();
frame.repaint();
}
}
private class BackAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {

Loading…
Cancel
Save