From 081dc19237a536056e578923fc3a704138dcc821 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Thu, 23 Dec 2021 16:42:53 +0100 Subject: [PATCH] gameexplorer: added gui layout --- .../de/tims/gameexplorer/GameExplorer.java | 79 ++++++++++++++++++- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/tims/gameexplorer/GameExplorer.java b/src/main/java/de/tims/gameexplorer/GameExplorer.java index 3ca8927..e77b246 100644 --- a/src/main/java/de/tims/gameexplorer/GameExplorer.java +++ b/src/main/java/de/tims/gameexplorer/GameExplorer.java @@ -1,33 +1,104 @@ package de.tims.gameexplorer; +import java.awt.*; import javax.swing.*; public class GameExplorer { private JFrame frame; private JPanel explorerPanel; + private JPanel border1; + private JPanel border2; + private JPanel border3; + private JPanel border4; + private JPanel border5; private JButton fleetstormBtn; private JButton fourwinsBtn; private JButton tictactoeBtn; private JButton leaderboardBtn; + private Dimension minSize; + private Dimension btnSize; + private GridBagConstraints gbc; public GameExplorer() { frame = new JFrame("1000 infomagische Spiele"); + + minSize = new Dimension(400, 300); + btnSize = new Dimension(160, 40); + gbc = new GridBagConstraints(); explorerPanel = new JPanel(); + explorerPanel.setLayout(new GridBagLayout()); fleetstormBtn = new JButton("Schiffe versenken"); + fleetstormBtn.setPreferredSize(btnSize); fourwinsBtn = new JButton("Vier gewinnt"); + fourwinsBtn.setPreferredSize(btnSize); tictactoeBtn = new JButton("TicTacToe"); + tictactoeBtn.setPreferredSize(btnSize); leaderboardBtn = new JButton("Leaderboard"); + leaderboardBtn.setPreferredSize(btnSize); + + border1 = new JPanel(); + border1.setOpaque(false); + border2 = new JPanel(); + border2.setOpaque(false); + border3 = new JPanel(); + border3.setOpaque(false); + border4 = new JPanel(); + border4.setOpaque(false); + border5 = new JPanel(); + border5.setOpaque(false); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weighty = 0.2; + explorerPanel.add(border1, gbc); + + gbc.gridx = 0; + gbc.gridy = 1; + gbc.weighty = 0.0; + explorerPanel.add(fleetstormBtn, gbc); + + gbc.gridx = 0; + gbc.gridy = 2; + gbc.weighty = 0.2; + explorerPanel.add(border2, gbc); - explorerPanel.add(fleetstormBtn); - explorerPanel.add(fourwinsBtn); - explorerPanel.add(tictactoeBtn); - explorerPanel.add(leaderboardBtn); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.weighty = 0.0; + explorerPanel.add(fourwinsBtn, gbc); + + gbc.gridx = 0; + gbc.gridy = 4; + gbc.weighty = 0.2; + explorerPanel.add(border3, gbc); + + gbc.gridx = 0; + gbc.gridy = 5; + gbc.weighty = 0.0; + explorerPanel.add(tictactoeBtn, gbc); + + gbc.gridx = 0; + gbc.gridy = 6; + gbc.weighty = 0.2; + explorerPanel.add(border4, gbc); + + gbc.gridx = 0; + gbc.gridy = 7; + gbc.weighty = 0.0; + explorerPanel.add(leaderboardBtn, gbc); + gbc.gridx = 0; + gbc.gridy = 8; + gbc.weighty = 0.2; + explorerPanel.add(border5, gbc); + frame.add(explorerPanel); + frame.setMinimumSize(minSize); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(640, 480); frame.setResizable(true); frame.setVisible(true);