Browse Source

added GridBagLayout for restart button

master
Ozan-Can Ekinci 2 years ago
parent
commit
e2bcd2a2fc
  1. 8
      src/main/java/Gui/GameGui.java

8
src/main/java/Gui/GameGui.java

@ -46,7 +46,8 @@ GridBagConstraints gbc;
public void createLosingPanel() { public void createLosingPanel() {
MainPanel.setVisible(false); MainPanel.setVisible(false);
ButtonPanel.setVisible(false); ButtonPanel.setVisible(false);
LosingPanel = new JPanel(new GridLayout());
LosingPanel = new JPanel();
LosingPanel.setLayout(new GridBagLayout());
LosingLabel = new JLabel("Du hast Verloren!"); LosingLabel = new JLabel("Du hast Verloren!");
LosingLabel.setVerticalAlignment(JLabel.CENTER); LosingLabel.setVerticalAlignment(JLabel.CENTER);
LosingLabel.setHorizontalAlignment(JLabel.CENTER); LosingLabel.setHorizontalAlignment(JLabel.CENTER);
@ -129,8 +130,11 @@ GridBagConstraints gbc;
@Override @Override
public void createRestartButton() { public void createRestartButton() {
GridBagConstraints gbc = new GridBagConstraints();
RestartBtn = new JButton("Neustarten"); RestartBtn = new JButton("Neustarten");
LosingPanel.add(RestartBtn);
LosingPanel.add(LosingLabel,gbc);
LosingPanel.add(RestartBtn,gbc);
RestartBtn.addActionListener(new RestartGame()); RestartBtn.addActionListener(new RestartGame());
} }
} }
Loading…
Cancel
Save