Browse Source

4gewinnt: finished gui layout

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
973c03544b
  1. 29
      src/main/java/de/tims/viergewinnt/ai/Logic.java

29
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -1,33 +1,56 @@
package de.tims.viergewinnt.ai;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Logic {
//"static" only for testing, remove when finished
//only for testing, remove when finished
static JFrame content;
static JPanel contentPanel;
static JPanel buttonPanel;
static JPanel playfieldPanel;
static JButton[] buttons = new JButton[6];
static JLabel[] gamefield = new JLabel[36];
public static JPanel create4gewinntGui() {
//only for testing, remove when finished
content = new JFrame();
content.setSize(200,200);
content.setSize(500,500);
contentPanel = new JPanel();
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));
//only for testing, remove when finished
content.add(contentPanel);
buttonPanel = new JPanel();
playfieldPanel = new JPanel();
buttonPanel = new JPanel(new GridLayout(1, 6));
playfieldPanel = new JPanel(new GridLayout(6, 6));
contentPanel.add(buttonPanel);
contentPanel.add(playfieldPanel);
for(int i = 0; i < buttons.length; i++) {
buttons[i] = new JButton(Integer.toString(i+1));
buttonPanel.add(buttons[i]);
}
for(int i = 0; i < gamefield.length; i++) {
gamefield[i] = new JLabel();
gamefield[i].setBorder(BorderFactory.createLineBorder(Color.gray));
playfieldPanel.add(gamefield[i]);
}
return contentPanel;
}

Loading…
Cancel
Save