From 8b2f6e2a2fbd9597bb278bb1a629f8b189e79911 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Sat, 22 Jan 2022 17:43:06 +0100 Subject: [PATCH] gameexplorer_gui: added logout and exit button --- .../de/tims/gameexplorer/GameExplorer.java | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/tims/gameexplorer/GameExplorer.java b/src/main/java/de/tims/gameexplorer/GameExplorer.java index 6f67e58..07915d1 100644 --- a/src/main/java/de/tims/gameexplorer/GameExplorer.java +++ b/src/main/java/de/tims/gameexplorer/GameExplorer.java @@ -25,11 +25,14 @@ public class GameExplorer { private JPanel border4; private JPanel border5; private JPanel border6; + private JPanel border7; private JButton loginBtn; private JButton fleetstormBtn; private JButton fourwinsBtn; private JButton tictactoeBtn; private JButton leaderboardBtn; + private JButton logoutBtn; + private JButton exitBtn; private JButton backBtn; private JLabel username; private JLabel loginWarning; @@ -38,6 +41,7 @@ public class GameExplorer { private Dimension minSize; private Dimension loginBtnSize; private Dimension btnSize; + private Dimension smallBtnSize; private GridBagConstraints gbc; private static final String playerFile = "src/main/java/resources/player_data.csv"; @@ -55,6 +59,7 @@ public class GameExplorer { minSize = new Dimension(400, 300); loginBtnSize = new Dimension(91, 20); btnSize = new Dimension(160, 40); + smallBtnSize = new Dimension(75, 30); gbc = new GridBagConstraints(); buildExplorerPanel(); @@ -87,6 +92,10 @@ public class GameExplorer { leaderboardBtn = new JButton("Leaderboard"); leaderboardBtn.setPreferredSize(btnSize); leaderboardBtn.addActionListener(new GameAction()); + logoutBtn = new JButton("Logout"); + logoutBtn.setPreferredSize(smallBtnSize); + exitBtn = new JButton("Exit"); + exitBtn.setPreferredSize(smallBtnSize); border1 = new JPanel(); border1.setOpaque(false); @@ -98,51 +107,82 @@ public class GameExplorer { border4.setOpaque(false); border5 = new JPanel(); border5.setOpaque(false); + border7 = new JPanel(); + border7.setOpaque(false); gbc.gridx = 0; gbc.gridy = 0; - gbc.weighty = 0.2; + gbc.gridwidth = 3; + gbc.weighty = 1.0 / 6; explorerPanel.add(border1, gbc); gbc.gridx = 0; gbc.gridy = 1; + gbc.gridwidth = 3; gbc.weighty = 0.0; explorerPanel.add(fleetstormBtn, gbc); gbc.gridx = 0; gbc.gridy = 2; - gbc.weighty = 0.2; + gbc.gridwidth = 3; + gbc.weighty = 1.0 / 6; explorerPanel.add(border2, gbc); gbc.gridx = 0; gbc.gridy = 3; + gbc.gridwidth = 3; gbc.weighty = 0.0; explorerPanel.add(fourwinsBtn, gbc); gbc.gridx = 0; gbc.gridy = 4; - gbc.weighty = 0.2; + gbc.gridwidth = 3; + gbc.weighty = 1.0 / 6; explorerPanel.add(border3, gbc); gbc.gridx = 0; gbc.gridy = 5; + gbc.gridwidth = 3; gbc.weighty = 0.0; explorerPanel.add(tictactoeBtn, gbc); gbc.gridx = 0; gbc.gridy = 6; - gbc.weighty = 0.2; + gbc.gridwidth = 3; + gbc.weighty = 1.0 / 6; explorerPanel.add(border4, gbc); gbc.gridx = 0; gbc.gridy = 7; + gbc.gridwidth = 3; gbc.weighty = 0.0; explorerPanel.add(leaderboardBtn, gbc); - + gbc.gridx = 0; gbc.gridy = 8; - gbc.weighty = 0.2; + gbc.weighty = 1.0 / 6; explorerPanel.add(border5, gbc); + + gbc.gridx = 0; + gbc.gridy = 9; + gbc.gridwidth = 1; + gbc.weighty = 0.0; + gbc.insets = new Insets(0, 0, 0, 5); + explorerPanel.add(logoutBtn, gbc); + + gbc.gridx = 2; + gbc.gridy = 9; + gbc.gridwidth = 1; + gbc.weighty = 0.0; + gbc.insets = new Insets(0, 5, 0, 0); + explorerPanel.add(exitBtn, gbc); + + gbc.insets = new Insets(0, 0, 0, 0); + gbc.gridx = 0; + gbc.gridy = 10; + gbc.gridwidth = 3; + gbc.weighty = 1.0 / 6; + explorerPanel.add(border7, gbc); } private void buildLoginPanel() { @@ -245,8 +285,6 @@ public class GameExplorer { frame.add(explorerPanel); frame.revalidate(); frame.repaint(); - - System.out.println("Actual Player: " + actualPlayer.getName() + ", Points: " + actualPlayer.getPoints()); } else { loginWarning.setText("Kein Name eingegeben!"); }