From e2bcd2a2fc6dd472e9a93dc440be80514232083a Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Wed, 11 Jan 2023 21:48:39 +0100 Subject: [PATCH] added GridBagLayout for restart button --- src/main/java/Gui/GameGui.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index 5a35231..1649804 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -46,7 +46,8 @@ GridBagConstraints gbc; public void createLosingPanel() { MainPanel.setVisible(false); ButtonPanel.setVisible(false); - LosingPanel = new JPanel(new GridLayout()); + LosingPanel = new JPanel(); + LosingPanel.setLayout(new GridBagLayout()); LosingLabel = new JLabel("Du hast Verloren!"); LosingLabel.setVerticalAlignment(JLabel.CENTER); LosingLabel.setHorizontalAlignment(JLabel.CENTER); @@ -129,8 +130,11 @@ GridBagConstraints gbc; @Override public void createRestartButton() { + GridBagConstraints gbc = new GridBagConstraints(); RestartBtn = new JButton("Neustarten"); - LosingPanel.add(RestartBtn); + LosingPanel.add(LosingLabel,gbc); + LosingPanel.add(RestartBtn,gbc); + RestartBtn.addActionListener(new RestartGame()); } }