Browse Source

refactoring: Split method into multiple methods

master
Leon Montag 2 years ago
parent
commit
db466546dc
  1. 20
      src/main/java/Gui/GameGui.java

20
src/main/java/Gui/GameGui.java

@ -20,8 +20,15 @@ public static int questionNr = 0;
GridLayout grid; GridLayout grid;
GridBagConstraints gbc; GridBagConstraints gbc;
public void createGui() { public void createGui() {
CreatePanel();
createHeadline();
createQuestionLabel();
createLayout();
createButtons();
}
public void CreatePanel(){
MainPanel = new JPanel(); MainPanel = new JPanel();
ButtonPanel = new JPanel(); ButtonPanel = new JPanel();
headingPanel = new JPanel(); headingPanel = new JPanel();
@ -29,16 +36,22 @@ GridBagConstraints gbc;
grid.setVgap(150); grid.setVgap(150);
headingPanel.setLayout(grid); headingPanel.setLayout(grid);
gui.Frame.add(MainPanel); gui.Frame.add(MainPanel);
}
public void createHeadline() {
Headline = new JLabel("Wer wird Millionär?"); Headline = new JLabel("Wer wird Millionär?");
headingPanel.add(Headline); headingPanel.add(Headline);
MainPanel.add(headingPanel); MainPanel.add(headingPanel);
Headline.setHorizontalAlignment(JLabel.CENTER); Headline.setHorizontalAlignment(JLabel.CENTER);
Headline.setFont(new Font("Serif", Font.BOLD, 28)); Headline.setFont(new Font("Serif", Font.BOLD, 28));
}
public void createQuestionLabel() {
QuestionLabel = new JLabel("Questions"); QuestionLabel = new JLabel("Questions");
MainPanel.add(QuestionLabel); MainPanel.add(QuestionLabel);
QuestionLabel.setHorizontalAlignment(JLabel.CENTER); QuestionLabel.setHorizontalAlignment(JLabel.CENTER);
QuestionLabel.setVerticalAlignment(JLabel.NORTH); QuestionLabel.setVerticalAlignment(JLabel.NORTH);
headingPanel.add(QuestionLabel); headingPanel.add(QuestionLabel);
}
public void createLayout() {
ButtonPanel.setLayout(new GridBagLayout()); ButtonPanel.setLayout(new GridBagLayout());
gbc = new GridBagConstraints(); gbc = new GridBagConstraints();
gbc.gridwidth = 1; gbc.gridwidth = 1;
@ -46,7 +59,9 @@ GridBagConstraints gbc;
gbc.insets = new Insets(10,10,10,10); gbc.insets = new Insets(10,10,10,10);
gbc.ipadx = 300; gbc.ipadx = 300;
gbc.ipady = 100; gbc.ipady = 100;
}
public void createButtons() {
AnswersBtn1 = new JButton(); AnswersBtn1 = new JButton();
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 0; gbc.gridy = 0;
@ -68,6 +83,5 @@ GridBagConstraints gbc;
ButtonPanel.add(AnswersBtn4,gbc); ButtonPanel.add(AnswersBtn4,gbc);
ButtonPanel.setVisible(true); ButtonPanel.setVisible(true);
MainPanel.add(ButtonPanel); MainPanel.add(ButtonPanel);
} }
} }
Loading…
Cancel
Save