From db466546dce88477af2f5cfcc468368a3f025b52 Mon Sep 17 00:00:00 2001 From: Leon Montag Date: Fri, 30 Dec 2022 19:22:51 +0100 Subject: [PATCH] refactoring: Split method into multiple methods --- src/main/java/Gui/GameGui.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index 65ccf3a..2181b0c 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -20,8 +20,15 @@ public static int questionNr = 0; GridLayout grid; GridBagConstraints gbc; - public void createGui() { + CreatePanel(); + createHeadline(); + createQuestionLabel(); + createLayout(); + createButtons(); + } + + public void CreatePanel(){ MainPanel = new JPanel(); ButtonPanel = new JPanel(); headingPanel = new JPanel(); @@ -29,16 +36,22 @@ GridBagConstraints gbc; grid.setVgap(150); headingPanel.setLayout(grid); gui.Frame.add(MainPanel); + } + public void createHeadline() { Headline = new JLabel("Wer wird Millionär?"); headingPanel.add(Headline); MainPanel.add(headingPanel); Headline.setHorizontalAlignment(JLabel.CENTER); Headline.setFont(new Font("Serif", Font.BOLD, 28)); + } + public void createQuestionLabel() { QuestionLabel = new JLabel("Questions"); MainPanel.add(QuestionLabel); QuestionLabel.setHorizontalAlignment(JLabel.CENTER); QuestionLabel.setVerticalAlignment(JLabel.NORTH); headingPanel.add(QuestionLabel); + } + public void createLayout() { ButtonPanel.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.gridwidth = 1; @@ -46,7 +59,9 @@ GridBagConstraints gbc; gbc.insets = new Insets(10,10,10,10); gbc.ipadx = 300; gbc.ipady = 100; - + } + + public void createButtons() { AnswersBtn1 = new JButton(); gbc.gridx = 0; gbc.gridy = 0; @@ -68,6 +83,5 @@ GridBagConstraints gbc; ButtonPanel.add(AnswersBtn4,gbc); ButtonPanel.setVisible(true); MainPanel.add(ButtonPanel); - } }