Browse Source

refactoring: moved createRestartButton method to LosingPanel

master
Ozan-Can Ekinci 2 years ago
parent
commit
1f5aa08c71
  1. 35
      src/main/java/Gui/GameGui.java
  2. 2
      src/main/java/Gui/GameGuiInterface.java
  3. 1
      src/main/java/game/loadNextQuestion.java

35
src/main/java/Gui/GameGui.java

@ -46,13 +46,29 @@ GridBagConstraints gbc;
public void createLosingPanel() { public void createLosingPanel() {
MainPanel.setVisible(false); MainPanel.setVisible(false);
ButtonPanel.setVisible(false); ButtonPanel.setVisible(false);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipadx = 200;
gbc.ipady = 100;
gbc.insets = new Insets(20, 0, 0, 0);
RestartBtn = new JButton("Neustarten");
ClosingBtn = new JButton("Schliessen");
LosingPanel = new JPanel(); LosingPanel = new JPanel();
LosingPanel.setLayout(new GridBagLayout()); 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);
LosingLabel.setFont(new Font("Serif", Font.BOLD, 28)); LosingLabel.setFont(new Font("Serif", Font.BOLD, 28));
LosingPanel.add(LosingLabel);
LosingPanel.add(LosingLabel,gbc);
LosingPanel.add(RestartBtn,gbc);
LosingPanel.add(ClosingBtn,gbc);
RestartBtn.addActionListener(new ActionHandler());
ClosingBtn.addActionListener(new ActionHandler());
gui.Frame.add(LosingPanel); gui.Frame.add(LosingPanel);
} }
@ -128,22 +144,5 @@ GridBagConstraints gbc;
MainPanel.add(ButtonPanel); MainPanel.add(ButtonPanel);
} }
@Override
public void createRestartButton() {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipadx = 200;
gbc.ipady = 100;
gbc.insets = new Insets(20, 0, 0, 0);
RestartBtn = new JButton("Neustarten");
ClosingBtn = new JButton("Schliessen");
LosingPanel.add(LosingLabel,gbc);
LosingPanel.add(RestartBtn,gbc);
LosingPanel.add(ClosingBtn,gbc);
RestartBtn.addActionListener(new ActionHandler());
ClosingBtn.addActionListener(new ActionHandler());
}
} }

2
src/main/java/Gui/GameGuiInterface.java

@ -18,6 +18,4 @@ public interface GameGuiInterface {
void createButtons(); void createButtons();
void createRestartButton();
} }

1
src/main/java/game/loadNextQuestion.java

@ -59,7 +59,6 @@ public class loadNextQuestion implements ActionListener {
public void wrongAnswer() { public void wrongAnswer() {
gameStatus.createLosingPanel(); gameStatus.createLosingPanel();
gameStatus.createRestartButton();
} }
} }
Loading…
Cancel
Save