Online-TicTacToe

Log | Files | Refs | README | LICENSE

commit 802b34ff87c118742056fe87ff2e690e4a7d87ae
parent 54b270892f74d3dca7a3fbb48d3e45aa005fce35
Author: adglas21 <adamglasheen99@gmail.com>
Date:   Wed, 27 Nov 2024 17:37:54 +0000

Logout button working

Diffstat:
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java | 18+++++++++++++++++-
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java | 13+++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java @@ -16,7 +16,6 @@ public class MainContentPanel extends CustomPanel { private int remainingTime; private TicTacToeGrid grid; private JLabel gameStatusLabel; - private JLabel currentGameLabel; @@ -60,6 +59,7 @@ public class MainContentPanel extends CustomPanel { add(scoreButton); add(currentGameLabel); add(forfeitButton); + add(logoutButton); layout.putConstraint(SpringLayout.WEST, createGameButton, 20, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, createGameButton, 10, SpringLayout.NORTH, this); @@ -97,6 +97,10 @@ public class MainContentPanel extends CustomPanel { layout.putConstraint(SpringLayout.NORTH, grid, 40, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.SOUTH, grid, 240, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.EAST, grid, -20, SpringLayout.EAST, this); + + layout.putConstraint(SpringLayout.SOUTH, logoutButton, -80, SpringLayout.SOUTH, this); + layout.putConstraint(SpringLayout.EAST, logoutButton, -20, SpringLayout.EAST, this); + layout.putConstraint(SpringLayout.SOUTH, scoreButton, -20, SpringLayout.SOUTH, this); layout.putConstraint(SpringLayout.EAST, scoreButton, -20, SpringLayout.EAST, this); @@ -149,6 +153,18 @@ public class MainContentPanel extends CustomPanel { }); + //logout button + logoutButton.addActionListener(e -> { + + //reset the client info + client.logout(); + + //go back to the start panel + client.showPanel(new login(client)); + + }); + + // //forfeit button action listener // forfeitButton.addActionListener(e -> { // if(client.UID.equals(client.HOST_UID)) diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java @@ -92,7 +92,20 @@ public class TicTacToeClient { this.UID2 = null; this.HOST_UID = ""; this.NUM_OF_MOVES = 0; + this.BOARD = new int [2][2]; refreshCurrentPanel(); } + + + + public void logout(){ + this.UID = null; + this.GID = ""; + this.UID2 = null; + this.HOST_UID = ""; + this.NUM_OF_MOVES = 0; + this.BOARD = new int [2][2]; + + } }