Browse Source

gameexplorer_gui: gameexplorer gui shows name and points of actual player

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

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

@ -36,6 +36,10 @@ public class GameExplorer {
private JButton backBtn;
private JLabel username;
private JLabel loginWarning;
private JLabel playerName;
private JLabel playerPoints;
private JLabel actualPlayerName;
private JLabel actualPlayerPoints;
private JLabel chosenGame;
private JTextField usernameInput;
private Dimension minSize;
@ -56,13 +60,12 @@ public class GameExplorer {
frame = new JFrame("1000 infomagische Spiele");
minSize = new Dimension(400, 300);
minSize = new Dimension(480, 360);
loginBtnSize = new Dimension(91, 20);
btnSize = new Dimension(160, 40);
smallBtnSize = new Dimension(75, 30);
gbc = new GridBagConstraints();
buildExplorerPanel();
buildLoginPanel();
buildNavigationPanel();
buildGamePanels();
@ -80,6 +83,11 @@ public class GameExplorer {
explorerPanel = new JPanel();
explorerPanel.setLayout(new GridBagLayout());
playerName = new JLabel("Spieler:");
playerPoints = new JLabel("Punkte:");
actualPlayerName = new JLabel(actualPlayer.getName());
actualPlayerPoints = new JLabel("" + actualPlayer.getPoints());
fleetstormBtn = new JButton("Schiffe versenken");
fleetstormBtn.setPreferredSize(btnSize);
fleetstormBtn.addActionListener(new GameAction());
@ -112,6 +120,9 @@ public class GameExplorer {
border7 = new JPanel();
border7.setOpaque(false);
gbc.weightx = 0.0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets(0, 0, 0, 0);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 3;
@ -162,6 +173,7 @@ public class GameExplorer {
gbc.gridx = 0;
gbc.gridy = 8;
gbc.gridwidth = 3;
gbc.weighty = 1.0 / 6;
explorerPanel.add(border5, gbc);
@ -169,6 +181,7 @@ public class GameExplorer {
gbc.gridy = 9;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(0, 0, 0, 5);
explorerPanel.add(logoutBtn, gbc);
@ -176,15 +189,47 @@ public class GameExplorer {
gbc.gridy = 9;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(0, 5, 0, 0);
explorerPanel.add(exitBtn, gbc);
gbc.anchor = GridBagConstraints.CENTER;
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);
gbc.gridx = 0;
gbc.gridy = 11;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.LINE_END;
explorerPanel.add(playerName, gbc);
gbc.gridx = 2;
gbc.gridy = 11;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.insets = new Insets(0, 5, 0, 0);
gbc.anchor = GridBagConstraints.LINE_START;
explorerPanel.add(actualPlayerName, gbc);
gbc.gridx = 0;
gbc.gridy = 12;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.LINE_END;
explorerPanel.add(playerPoints, gbc);
gbc.gridx = 2;
gbc.gridy = 12;
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.insets = new Insets(0, 5, 0, 0);
gbc.anchor = GridBagConstraints.LINE_START;
explorerPanel.add(actualPlayerPoints, gbc);
}
private void buildLoginPanel() {
@ -198,7 +243,10 @@ public class GameExplorer {
loginWarning = new JLabel();
usernameInput = new JTextField(8);
gbc.weighty = 0;
gbc.gridwidth = 1;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 0, 5, 0);
@ -232,7 +280,9 @@ public class GameExplorer {
border6 = new JPanel();
border6.setOpaque(false);
gbc.gridwidth = 1;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.0;
@ -283,6 +333,8 @@ public class GameExplorer {
manager.loadPlayers(PLAYER_FILE);
actualPlayer = manager.selectPlayer(userInput);
buildExplorerPanel();
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.remove(loginPanel);
frame.add(explorerPanel);
@ -365,6 +417,8 @@ public class GameExplorer {
gamePanel.remove(leaderboardPanel);
}
actualPlayerPoints.setText("" + actualPlayer.getPoints());
frame.remove(gamePanel);
frame.add(explorerPanel);
frame.revalidate();

Loading…
Cancel
Save