From e2f986b320574f5cd37ee0ca79e0bf855cb34023 Mon Sep 17 00:00:00 2001 From: Leon Montag Date: Sat, 28 Jan 2023 19:43:37 +0100 Subject: [PATCH] Add Start Button for Tic Tac Toe Game --- src/main/java/Gui/StartGameGui.java | 6 +++++- src/main/java/Gui/gui.java | 9 +++++--- src/main/java/game/StartTicTacToeGame.java | 5 +++++ src/test/java/Gui/guiTest.java | 2 +- .../compile/default-compile/inputFiles.lst | 21 ++++++++++--------- .../default-testCompile/inputFiles.lst | 10 ++++----- 6 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 src/main/java/game/StartTicTacToeGame.java diff --git a/src/main/java/Gui/StartGameGui.java b/src/main/java/Gui/StartGameGui.java index 5993265..e9a1359 100644 --- a/src/main/java/Gui/StartGameGui.java +++ b/src/main/java/Gui/StartGameGui.java @@ -4,6 +4,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import game.StartDarkSoulsGame; +import game.StartTicTacToeGame; import game.runGame; public class StartGameGui implements ActionListener { @@ -13,9 +14,12 @@ public class StartGameGui implements ActionListener { gui.Panel.setVisible(false); if(e.getSource() == gui.StartBtn) { startGame(); - } else { + } else if(e.getSource() == gui.StartDarkSoulsBtn) { new StartDarkSoulsGame(); } + else if(e.getSource() == gui.StartTicTacToeBtn) { + new StartTicTacToeGame(); + } } public void startGame() { diff --git a/src/main/java/Gui/gui.java b/src/main/java/Gui/gui.java index af61c9f..d265cca 100644 --- a/src/main/java/Gui/gui.java +++ b/src/main/java/Gui/gui.java @@ -12,7 +12,7 @@ import javax.swing.JPanel; public class gui implements GuiInterface { public static JFrame Frame; - public static JButton StartBtn, CloseBtn, StartDarkSoulsBtn; + public static JButton StartBtn, CloseBtn, StartDarkSoulsBtn,StartTicTacToeBtn; public static JPanel Panel; public static JLabel Label; public static int status = 0; @@ -40,6 +40,8 @@ public class gui implements GuiInterface { StartBtn.addActionListener(new StartGameGui()); StartDarkSoulsBtn = new JButton("Starte Dark Souls 4"); StartDarkSoulsBtn.addActionListener(new StartGameGui()); + StartTicTacToeBtn = new JButton("Starte Tic Tac Toe"); + StartTicTacToeBtn.addActionListener(new StartGameGui()); CloseBtn = new JButton("Schliessen"); CloseBtn.addActionListener(new ActionHandler()); @@ -54,14 +56,15 @@ public class gui implements GuiInterface { gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.ipadx = 300; - gbc.ipady = 100; - gbc.insets = new Insets(20, 0, 0, 0); + gbc.ipady = 50; + gbc.insets = new Insets(10, 0, 0, 0); Label = new JLabel("MiniGames"); Label.setHorizontalAlignment(JLabel.CENTER); Label.setFont(new Font("Serif", Font.BOLD, 28)); Panel.add(Label, gbc); Panel.add(StartBtn, gbc); Panel.add(StartDarkSoulsBtn, gbc); + Panel.add(StartTicTacToeBtn,gbc); Panel.add(CloseBtn, gbc); Frame.add(Panel); Frame.setVisible(true); diff --git a/src/main/java/game/StartTicTacToeGame.java b/src/main/java/game/StartTicTacToeGame.java new file mode 100644 index 0000000..84fd40b --- /dev/null +++ b/src/main/java/game/StartTicTacToeGame.java @@ -0,0 +1,5 @@ +package game; + +public class StartTicTacToeGame { + +} diff --git a/src/test/java/Gui/guiTest.java b/src/test/java/Gui/guiTest.java index f9d6f4f..d088cca 100644 --- a/src/test/java/Gui/guiTest.java +++ b/src/test/java/Gui/guiTest.java @@ -42,7 +42,7 @@ class guiTest { @Test public void testCreatePanel() { // arrange - int NumPanels = 4; + int NumPanels = 5; // act int TargetNumPanels = gui.Panel.getComponents().length; diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index fd44bf8..dcad9f5 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,10 +1,11 @@ -C:\Users\yazan\MiniGameProject\src\main\java\game\StartDarkSoulsGame.java -C:\Users\yazan\MiniGameProject\src\main\java\game\runGame.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\gui.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\StartGameGui.java -C:\Users\yazan\MiniGameProject\src\main\java\game\loadNextQuestion.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\ActionHandler.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\GameGui.java -C:\Users\yazan\MiniGameProject\src\main\java\main.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\GameGuiInterface.java -C:\Users\yazan\MiniGameProject\src\main\java\Gui\GuiInterface.java +C:\Users\Leon\MiniGameProject\src\main\java\game\StartTicTacToeGame.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\ActionHandler.java +C:\Users\Leon\MiniGameProject\src\main\java\game\loadNextQuestion.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\GameGuiInterface.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\gui.java +C:\Users\Leon\MiniGameProject\src\main\java\game\runGame.java +C:\Users\Leon\MiniGameProject\src\main\java\game\StartDarkSoulsGame.java +C:\Users\Leon\MiniGameProject\src\main\java\main.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\StartGameGui.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\GameGui.java +C:\Users\Leon\MiniGameProject\src\main\java\Gui\GuiInterface.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index 470a3c7..93bde8b 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -1,5 +1,5 @@ -C:\Users\yazan\MiniGameProject\src\test\java\game\loadNextQuestionTest.java -C:\Users\yazan\MiniGameProject\src\test\java\Gui\guiTest.java -C:\Users\yazan\MiniGameProject\src\test\java\Gui\GameGuiTest.java -C:\Users\yazan\MiniGameProject\src\test\java\game\runGameTest.java -C:\Users\yazan\MiniGameProject\src\test\java\Gui\ActionHandlerTest.java +C:\Users\Leon\MiniGameProject\src\test\java\Gui\guiTest.java +C:\Users\Leon\MiniGameProject\src\test\java\game\loadNextQuestionTest.java +C:\Users\Leon\MiniGameProject\src\test\java\Gui\ActionHandlerTest.java +C:\Users\Leon\MiniGameProject\src\test\java\Gui\GameGuiTest.java +C:\Users\Leon\MiniGameProject\src\test\java\game\runGameTest.java