From 6e61c0424044412516e987b6db272bb4b8ed4100 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Sat, 15 Jan 2022 19:51:24 +0100 Subject: [PATCH] player_management: added layout for LoginPanel --- .../de/tims/gameexplorer/GameExplorer.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/tims/gameexplorer/GameExplorer.java b/src/main/java/de/tims/gameexplorer/GameExplorer.java index 8630841..ab88fa0 100644 --- a/src/main/java/de/tims/gameexplorer/GameExplorer.java +++ b/src/main/java/de/tims/gameexplorer/GameExplorer.java @@ -2,6 +2,7 @@ package de.tims.gameexplorer; import java.awt.*; import java.awt.event.*; + import javax.swing.*; public class GameExplorer { @@ -31,6 +32,7 @@ public class GameExplorer { private JLabel chosenGame; private JTextField usernameInput; private Dimension minSize; + private Dimension loginBtnSize; private Dimension btnSize; private GridBagConstraints gbc; @@ -41,6 +43,7 @@ public class GameExplorer { frame = new JFrame("1000 infomagische Spiele"); minSize = new Dimension(400, 300); + loginBtnSize = new Dimension(91, 20); btnSize = new Dimension(160, 40); gbc = new GridBagConstraints(); @@ -134,14 +137,28 @@ public class GameExplorer { private void buildLoginPanel() { loginPanel = new JPanel(); + loginPanel.setLayout(new GridBagLayout()); loginBtn = new JButton("Login"); + loginBtn.setPreferredSize(loginBtnSize); username = new JLabel("Name eingeben:"); - usernameInput = new JTextField(10); + usernameInput = new JTextField(8); - loginPanel.add(username); - loginPanel.add(usernameInput); - loginPanel.add(loginBtn); + gbc.weighty = 0; + gbc.gridx = 0; + gbc.gridy = 0; + gbc.insets = new Insets(0, 0, 5, 0); + loginPanel.add(username, gbc); + + gbc.gridx = 0; + gbc.gridy = 1; + gbc.insets = new Insets(5, 0, 5, 0); + loginPanel.add(usernameInput, gbc); + + gbc.gridx = 0; + gbc.gridy = 2; + gbc.insets = new Insets(5, 0, 0, 0); + loginPanel.add(loginBtn, gbc); } private void buildNavigationPanel() {