diff --git a/src/main/java/Gui/ActionHandler.java b/src/main/java/Gui/ActionHandler.java index 3f32cd8..9eca7bb 100644 --- a/src/main/java/Gui/ActionHandler.java +++ b/src/main/java/Gui/ActionHandler.java @@ -22,6 +22,12 @@ public class ActionHandler implements ActionListener { restartGame.startGame(); } + if (e.getSource() == GameGui.RestartBtn1) { + GameGui.questionNr = 0; + GameGui.WinningPanel.setVisible(false); + restartGame.startGame(); + } + } } diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index 9ce5fac..c88b72c 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -77,18 +77,23 @@ GridBagConstraints gbc; GameGui.MainPanel.setVisible(false); GameGui.ButtonPanel.setVisible(false); + GridBagConstraints gbc = new GridBagConstraints(); + RestartBtn1 = new JButton("Nochmal Spielen"); ClosingBtn = new JButton("Schliessen"); - WinningPanel = new JPanel(new GridLayout()); + WinningPanel = new JPanel(); + WinningPanel.setLayout(new GridBagLayout()); WinningLabel = new JLabel("Du hast Gewonnen!"); WinningLabel.setVerticalAlignment(JLabel.CENTER); WinningLabel.setHorizontalAlignment(JLabel.CENTER); 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); }