Browse Source

gameexplorer_gui: added logout and exit button

gameexplorer_gui
Tobias Krause 2 years ago
committed by Lorenz Hohmann
parent
commit
8b2f6e2a2f
  1. 54
      src/main/java/de/tims/gameexplorer/GameExplorer.java

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

@ -25,11 +25,14 @@ public class GameExplorer {
private JPanel border4; private JPanel border4;
private JPanel border5; private JPanel border5;
private JPanel border6; private JPanel border6;
private JPanel border7;
private JButton loginBtn; private JButton loginBtn;
private JButton fleetstormBtn; private JButton fleetstormBtn;
private JButton fourwinsBtn; private JButton fourwinsBtn;
private JButton tictactoeBtn; private JButton tictactoeBtn;
private JButton leaderboardBtn; private JButton leaderboardBtn;
private JButton logoutBtn;
private JButton exitBtn;
private JButton backBtn; private JButton backBtn;
private JLabel username; private JLabel username;
private JLabel loginWarning; private JLabel loginWarning;
@ -38,6 +41,7 @@ public class GameExplorer {
private Dimension minSize; private Dimension minSize;
private Dimension loginBtnSize; private Dimension loginBtnSize;
private Dimension btnSize; private Dimension btnSize;
private Dimension smallBtnSize;
private GridBagConstraints gbc; private GridBagConstraints gbc;
private static final String playerFile = "src/main/java/resources/player_data.csv"; private static final String playerFile = "src/main/java/resources/player_data.csv";
@ -55,6 +59,7 @@ public class GameExplorer {
minSize = new Dimension(400, 300); minSize = new Dimension(400, 300);
loginBtnSize = new Dimension(91, 20); loginBtnSize = new Dimension(91, 20);
btnSize = new Dimension(160, 40); btnSize = new Dimension(160, 40);
smallBtnSize = new Dimension(75, 30);
gbc = new GridBagConstraints(); gbc = new GridBagConstraints();
buildExplorerPanel(); buildExplorerPanel();
@ -87,6 +92,10 @@ public class GameExplorer {
leaderboardBtn = new JButton("Leaderboard"); leaderboardBtn = new JButton("Leaderboard");
leaderboardBtn.setPreferredSize(btnSize); leaderboardBtn.setPreferredSize(btnSize);
leaderboardBtn.addActionListener(new GameAction()); leaderboardBtn.addActionListener(new GameAction());
logoutBtn = new JButton("Logout");
logoutBtn.setPreferredSize(smallBtnSize);
exitBtn = new JButton("Exit");
exitBtn.setPreferredSize(smallBtnSize);
border1 = new JPanel(); border1 = new JPanel();
border1.setOpaque(false); border1.setOpaque(false);
@ -98,51 +107,82 @@ public class GameExplorer {
border4.setOpaque(false); border4.setOpaque(false);
border5 = new JPanel(); border5 = new JPanel();
border5.setOpaque(false); border5.setOpaque(false);
border7 = new JPanel();
border7.setOpaque(false);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
gbc.weighty = 0.2;
gbc.gridwidth = 3;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border1, gbc); explorerPanel.add(border1, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 1; gbc.gridy = 1;
gbc.gridwidth = 3;
gbc.weighty = 0.0; gbc.weighty = 0.0;
explorerPanel.add(fleetstormBtn, gbc); explorerPanel.add(fleetstormBtn, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 2; gbc.gridy = 2;
gbc.weighty = 0.2;
gbc.gridwidth = 3;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border2, gbc); explorerPanel.add(border2, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 3; gbc.gridy = 3;
gbc.gridwidth = 3;
gbc.weighty = 0.0; gbc.weighty = 0.0;
explorerPanel.add(fourwinsBtn, gbc); explorerPanel.add(fourwinsBtn, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 4; gbc.gridy = 4;
gbc.weighty = 0.2;
gbc.gridwidth = 3;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border3, gbc); explorerPanel.add(border3, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 5; gbc.gridy = 5;
gbc.gridwidth = 3;
gbc.weighty = 0.0; gbc.weighty = 0.0;
explorerPanel.add(tictactoeBtn, gbc); explorerPanel.add(tictactoeBtn, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 6; gbc.gridy = 6;
gbc.weighty = 0.2;
gbc.gridwidth = 3;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border4, gbc); explorerPanel.add(border4, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 7; gbc.gridy = 7;
gbc.gridwidth = 3;
gbc.weighty = 0.0; gbc.weighty = 0.0;
explorerPanel.add(leaderboardBtn, gbc); explorerPanel.add(leaderboardBtn, gbc);
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 8; gbc.gridy = 8;
gbc.weighty = 0.2;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border5, gbc); 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() { private void buildLoginPanel() {
@ -245,8 +285,6 @@ public class GameExplorer {
frame.add(explorerPanel); frame.add(explorerPanel);
frame.revalidate(); frame.revalidate();
frame.repaint(); frame.repaint();
System.out.println("Actual Player: " + actualPlayer.getName() + ", Points: " + actualPlayer.getPoints());
} else { } else {
loginWarning.setText("Kein Name eingegeben!"); loginWarning.setText("Kein Name eingegeben!");
} }

Loading…
Cancel
Save