From 973c03544bf98b7f522bb6fabd8e6778fb06b248 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 10 Jan 2022 12:32:49 +0100 Subject: [PATCH] 4gewinnt: finished gui layout --- .../java/de/tims/viergewinnt/ai/Logic.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index c4fc3d5..356a777 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/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; }