Browse Source

refactoring: Split one method into three for better readability

master
Leon Montag 2 years ago
parent
commit
344ef0a467
  1. 28
      src/main/java/Gui/gui.java
  2. 3
      src/main/java/main.java
  3. BIN
      target/MiniGameProject-1.0-SNAPSHOT.jar
  4. 2
      target/maven-archiver/pom.properties

28
src/main/java/Gui/gui.java

@ -11,24 +11,31 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
public class gui { public class gui {
JFrame jf;
JButton StartBtn, CloseBtn;
JPanel Panel;
JLabel Label;
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 static int width = 800, height = 600;
public void create(){
public void StartMainMenu() {
createFrame();
createButtons();
createPanel();
}
public void createFrame(){
jf = new JFrame("Wer wird Millionr"); jf = new JFrame("Wer wird Millionr");
jf.setSize(width,height); jf.setSize(width,height);
jf.setLocationRelativeTo(null); jf.setLocationRelativeTo(null);
jf.setResizable(false); jf.setResizable(false);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void createButtons() {
StartBtn = new JButton("Starte Spiel"); StartBtn = new JButton("Starte Spiel");
StartBtn.setSize(300,100);
CloseBtn = new JButton("Schlieen"); CloseBtn = new JButton("Schlieen");
CloseBtn.setSize(300,100);
}
public void createPanel() {
Panel = new JPanel(); Panel = new JPanel();
Panel.setSize(width,height); Panel.setSize(width,height);
Panel.setLayout(new GridBagLayout()); Panel.setLayout(new GridBagLayout());
@ -47,8 +54,7 @@ public class gui {
jf.add(Panel); jf.add(Panel);
jf.setVisible(true); jf.setVisible(true);
Panel.setVisible(true); Panel.setVisible(true);
} }
} }

3
src/main/java/main.java

@ -6,7 +6,8 @@ public class main {
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
gui Mainmenu = new gui(); gui Mainmenu = new gui();
Mainmenu.create();
Mainmenu.StartMainMenu();
} }
} }

BIN
target/MiniGameProject-1.0-SNAPSHOT.jar

2
target/maven-archiver/pom.properties

@ -1,5 +1,5 @@
#Generated by Maven #Generated by Maven
#Fri Dec 30 01:03:37 CET 2022
#Fri Dec 30 01:04:49 CET 2022
groupId=MiniGameProject groupId=MiniGameProject
artifactId=MiniGameProject artifactId=MiniGameProject
version=1.0-SNAPSHOT version=1.0-SNAPSHOT
Loading…
Cancel
Save