Browse Source

added GridBagLayout and functionality for buttons after winning

master
Ozan-Can Ekinci 2 years ago
parent
commit
dfbd3cd79d
  1. 6
      src/main/java/Gui/ActionHandler.java
  2. 13
      src/main/java/Gui/GameGui.java

6
src/main/java/Gui/ActionHandler.java

@ -22,6 +22,12 @@ public class ActionHandler implements ActionListener {
restartGame.startGame(); restartGame.startGame();
} }
if (e.getSource() == GameGui.RestartBtn1) {
GameGui.questionNr = 0;
GameGui.WinningPanel.setVisible(false);
restartGame.startGame();
}
} }
} }

13
src/main/java/Gui/GameGui.java

@ -77,18 +77,23 @@ GridBagConstraints gbc;
GameGui.MainPanel.setVisible(false); GameGui.MainPanel.setVisible(false);
GameGui.ButtonPanel.setVisible(false); GameGui.ButtonPanel.setVisible(false);
GridBagConstraints gbc = new GridBagConstraints();
RestartBtn1 = new JButton("Nochmal Spielen"); RestartBtn1 = new JButton("Nochmal Spielen");
ClosingBtn = new JButton("Schliessen"); ClosingBtn = new JButton("Schliessen");
WinningPanel = new JPanel(new GridLayout());
WinningPanel = new JPanel();
WinningPanel.setLayout(new GridBagLayout());
WinningLabel = new JLabel("Du hast Gewonnen!"); WinningLabel = new JLabel("Du hast Gewonnen!");
WinningLabel.setVerticalAlignment(JLabel.CENTER); WinningLabel.setVerticalAlignment(JLabel.CENTER);
WinningLabel.setHorizontalAlignment(JLabel.CENTER); WinningLabel.setHorizontalAlignment(JLabel.CENTER);
WinningLabel.setFont(new Font("Serif", Font.BOLD, 28)); WinningLabel.setFont(new Font("Serif", Font.BOLD, 28));
WinningPanel.add(WinningLabel);
WinningPanel.add(RestartBtn1);
WinningPanel.add(ClosingBtn);
WinningPanel.add(WinningLabel,gbc);
WinningPanel.add(RestartBtn1,gbc);
WinningPanel.add(ClosingBtn,gbc);
RestartBtn1.addActionListener(new ActionHandler());
ClosingBtn.addActionListener(new ActionHandler());
gui.Frame.add(WinningPanel); gui.Frame.add(WinningPanel);
} }

Loading…
Cancel
Save