From 936a563422f1268775e778d644c2fdabb3fd4628 Mon Sep 17 00:00:00 2001 From: Lorenz Hohmann Date: Wed, 12 Jan 2022 13:18:57 +0100 Subject: [PATCH] Created gui with minimal elements --- src/main/java/de/tims/fleetstorm/gui/GUI.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/main/java/de/tims/fleetstorm/gui/GUI.java diff --git a/src/main/java/de/tims/fleetstorm/gui/GUI.java b/src/main/java/de/tims/fleetstorm/gui/GUI.java new file mode 100644 index 0000000..70d3333 --- /dev/null +++ b/src/main/java/de/tims/fleetstorm/gui/GUI.java @@ -0,0 +1,63 @@ +package de.tims.fleetstorm.gui; + +import java.awt.Color; +import java.awt.Font; +import java.util.ArrayList; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.MatteBorder; + +public class GUI extends JPanel { + + private ArrayList fields; + + public GUI() { + this.fields = new ArrayList<>(); + setSize(640, 480); + + JPanel fieldWrapper = new JPanel(); + fieldWrapper.setBounds(10, 11, 362, 458); + fieldWrapper.setLayout(null); + + JPanel infoWrapper = new JPanel(); + infoWrapper.setBounds(382, 11, 248, 458); + + JLabel hasMoveLabel = new JLabel("Am Zug:"); + hasMoveLabel.setFont(new Font("Tahoma", Font.BOLD, 11)); + infoWrapper.add(hasMoveLabel); + + JLabel hasMove = new JLabel("Spieler"); + infoWrapper.add(hasMove); + setLayout(null); + add(fieldWrapper); + add(infoWrapper); + + int gap = 30; + int width = 28; + + for (int x = 0; x < 10; x++) { + for (int y = 0; y < 10; y++) { + JPanel field = new JPanel(); + field.setBounds(gap + x * width, gap + y * width, width, width); + field.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); + fields.add(field); + fieldWrapper.add(field); + } + } + + } + + /** + * This function is only for testing + */ + public static void main(String[] args) { + JFrame frame = new JFrame("Test GUI"); + GUI gui = new GUI(); + frame.setContentPane(gui); + frame.setSize(640, 480); + frame.setResizable(true); + frame.setVisible(true); + } +}