Browse Source

refactoring: Split method into multiple methods

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

18
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);
}
}
Loading…
Cancel
Save