Browse Source

refactoring: moved restart button functionality

master
Ozan-Can Ekinci 2 years ago
parent
commit
c81cc47769
  1. 6
      src/main/java/Gui/ActionHandler.java
  2. 2
      src/main/java/Gui/GameGui.java
  3. 20
      src/main/java/Gui/RestartGame.java
  4. 1
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

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

@ -5,6 +5,8 @@ import java.awt.event.ActionListener;
public class ActionHandler implements ActionListener {
StartGameGui restartGame = new StartGameGui();
public void actionPerformed(ActionEvent e) {
if (e.getSource() == gui.CloseBtn) {
System.exit(0);
@ -14,6 +16,10 @@ public class ActionHandler implements ActionListener {
System.exit(0);
}
GameGui.questionNr = 0;
GameGui.LosingPanel.setVisible(false);
restartGame.startGame();
}
}

2
src/main/java/Gui/GameGui.java

@ -143,7 +143,7 @@ GridBagConstraints gbc;
LosingPanel.add(RestartBtn,gbc);
LosingPanel.add(ClosingBtn,gbc);
RestartBtn.addActionListener(new RestartGame());
RestartBtn.addActionListener(new ActionHandler());
ClosingBtn.addActionListener(new ActionHandler());
}
}

20
src/main/java/Gui/RestartGame.java

@ -1,20 +0,0 @@
package Gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RestartGame implements ActionListener {
StartGameGui restartGame = new StartGameGui();
@Override
public void actionPerformed(ActionEvent e) {
GameGui.questionNr = 0;
GameGui.LosingPanel.setVisible(false);
restartGame.startGame();
}
}

1
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@ -1,5 +1,4 @@
C:\Users\ozan_\MiniGameProject\src\main\java\Gui\GuiInterface.java
C:\Users\ozan_\MiniGameProject\src\main\java\Gui\RestartGame.java
C:\Users\ozan_\MiniGameProject\src\main\java\Gui\GameGuiInterface.java
C:\Users\ozan_\MiniGameProject\src\main\java\Gui\gui.java
C:\Users\ozan_\MiniGameProject\src\main\java\game\loadNextQuestion.java

Loading…
Cancel
Save