From 344ef0a467092975fbd9f79f32a109a824fdebc6 Mon Sep 17 00:00:00 2001 From: Leon Montag Date: Fri, 30 Dec 2022 01:06:29 +0100 Subject: [PATCH] refactoring: Split one method into three for better readability --- src/main/java/Gui/gui.java | 32 ++++++++++++++---------- src/main/java/main.java | 3 ++- target/MiniGameProject-1.0-SNAPSHOT.jar | Bin 3609 -> 3609 bytes target/maven-archiver/pom.properties | 2 +- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/Gui/gui.java b/src/main/java/Gui/gui.java index 688597c..ef552d6 100644 --- a/src/main/java/Gui/gui.java +++ b/src/main/java/Gui/gui.java @@ -11,24 +11,31 @@ import javax.swing.JLabel; import javax.swing.JPanel; public class gui { - JFrame jf; - JButton StartBtn, CloseBtn; - JPanel Panel; - JLabel Label; - - - public static int width = 800, height = 600; - - public void create(){ + public static JFrame jf; + public static JButton StartBtn, CloseBtn; + public static JPanel Panel; + public static JLabel Label; + public static int width = 800, height = 600; + + public void StartMainMenu() { + createFrame(); + createButtons(); + createPanel(); + } + public void createFrame(){ jf = new JFrame("Wer wird Millionr"); jf.setSize(width,height); jf.setLocationRelativeTo(null); jf.setResizable(false); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + public void createButtons() { StartBtn = new JButton("Starte Spiel"); - StartBtn.setSize(300,100); CloseBtn = new JButton("Schlieen"); - CloseBtn.setSize(300,100); + + } + public void createPanel() { Panel = new JPanel(); Panel.setSize(width,height); Panel.setLayout(new GridBagLayout()); @@ -47,8 +54,7 @@ public class gui { jf.add(Panel); jf.setVisible(true); Panel.setVisible(true); - + } - } } diff --git a/src/main/java/main.java b/src/main/java/main.java index 4a9afbb..7c295f9 100644 --- a/src/main/java/main.java +++ b/src/main/java/main.java @@ -6,7 +6,8 @@ public class main { public static void main(String[] args) { // TODO Auto-generated method stub gui Mainmenu = new gui(); - Mainmenu.create(); + Mainmenu.StartMainMenu(); } } + diff --git a/target/MiniGameProject-1.0-SNAPSHOT.jar b/target/MiniGameProject-1.0-SNAPSHOT.jar index a4420dfac69f212a70095484fa3d77ec73d05b35..2fc77734cd8bb6088083626b2bfe33c35058523c 100644 GIT binary patch delta 144 zcmbO!GgF2;z?+$civa{?PUKc&oH5a8Hsj2R=M))dZv60;g>mNQd#r(sj58-2uhUGV+~|vES_w@t^*`v z*=>MAv)HdPaTIgR3$=dhd1rDtS3b)&BeU?yuebt%N^H2z7>gzsb2|drTe%H^