Changed frame size for all Gui and reworked chessPanel in GameGui

GitBranch^2
Justin 2025-06-23 23:11:23 +02:00
parent 66a8c1a51d
commit 35b7d9aa9a
4 changed files with 71 additions and 33 deletions

View File

@ -30,7 +30,8 @@ public class CreativeGui {
public CreativeGui() { public CreativeGui() {
frame = new JFrame("Creative Mode"); frame = new JFrame("Creative Mode");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(1600, 1200); frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setUndecorated(false);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
JPanel mainPanel = new JPanel(new GridBagLayout()); JPanel mainPanel = new JPanel(new GridBagLayout());

View File

@ -7,9 +7,12 @@ import java.awt.Font;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.Insets; import java.awt.Insets;
import java.util.List; import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -31,6 +34,7 @@ public class GameGui {
private JLabel whiteTimerLabel; private JLabel whiteTimerLabel;
private JLabel blackTimerLabel; private JLabel blackTimerLabel;
private JLabel openingLabel;
private JButton btnFirst = new JButton("|<"); private JButton btnFirst = new JButton("|<");
private JButton btnPrev = new JButton("<"); private JButton btnPrev = new JButton("<");
@ -54,7 +58,8 @@ public class GameGui {
public JFrame mainFrame() { public JFrame mainFrame() {
JFrame frame = new JFrame(); JFrame frame = new JFrame();
frame.setSize(1600, 1000); frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setUndecorated(false);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
frame.add(mainPanel()); frame.add(mainPanel());
@ -130,38 +135,68 @@ public class GameGui {
return boardPanel; return boardPanel;
} }
public JPanel chessPanel(JPanel panel) { public JPanel chessPanel(JPanel boardPanel) {
JPanel chessPanel = new JPanel(new GridBagLayout()); JPanel chessPanel = new JPanel(new BorderLayout());
GridBagConstraints board = new GridBagConstraints(); chessPanel.setBackground(new Color(0x1b263b));
chessPanel.setBackground(new Color(0x1b263b));
board.gridx = 0;
board.gridy = 0;
board.weightx = 0.7;
board.weighty = 1.0;
board.insets = new Insets(0, 0, 0, 0);
//oben, links, unten, rechts
board.fill = GridBagConstraints.BOTH;
chessPanel.add(panel);
// Button unten rechts
flipBoardButton = new JButton("⇵");
flipBoardButton.setPreferredSize(new Dimension(70, 70));
flipBoardButton.setFont(new Font("SansSerif", Font.BOLD, 40));
flipBoardButton.setBackground(new Color(0x5500ff));
flipBoardButton.setForeground(Color.WHITE);
flipBoardButton.setFocusPainted(false);
GridBagConstraints btn = new GridBagConstraints(); // --- Eröffnungslabel oben ---
btn.gridx = 0; openingLabel = new JLabel("Eröffnung: unbekannt", SwingConstants.CENTER);
btn.gridy = 1; openingLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
btn.weightx = 0.0; openingLabel.setForeground(Color.WHITE);
btn.weighty = 0.0; openingLabel.setOpaque(true);
btn.anchor = GridBagConstraints.SOUTHEAST; openingLabel.setBackground(new Color(0x283655));
btn.insets = new Insets(10, 0, 0, 0); openingLabel.setPreferredSize(new Dimension(800, 50));
chessPanel.add(openingLabel, BorderLayout.NORTH);
chessPanel.add(flipBoardButton, btn); // --- Board in ein zentriertes Panel mit fixer Größe ---
JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
return chessPanel; centerPanel.setOpaque(false);
boardPanel.setMaximumSize(new Dimension(800, 800));
boardPanel.setPreferredSize(new Dimension(800, 800));
centerPanel.add(boardPanel);
chessPanel.add(centerPanel, BorderLayout.CENTER);
// --- Dummy-Buffer für WEST und EAST ---
chessPanel.add(Box.createRigidArea(new Dimension(40, 0)), BorderLayout.WEST);
chessPanel.add(Box.createRigidArea(new Dimension(40, 0)), BorderLayout.EAST);
// --- Buttonleiste unten bauen ---
JPanel buttonRow = new JPanel();
buttonRow.setOpaque(false);
buttonRow.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 10, 0));
resignButton = new JButton("🛑");
resignButton.setPreferredSize(new Dimension(70, 70));
resignButton.setFont(new Font("SansSerif", Font.BOLD, 40));
resignButton.setBackground(new Color(0xff0044));
resignButton.setForeground(Color.WHITE);
resignButton.setFocusPainted(false);
drawButton = new JButton("½–½");
drawButton.setPreferredSize(new Dimension(70, 70));
drawButton.setFont(new Font("SansSerif", Font.BOLD, 40));
drawButton.setBackground(new Color(0x0080ff));
drawButton.setForeground(Color.WHITE);
drawButton.setFocusPainted(false);
flipBoardButton = new JButton("⇵");
flipBoardButton.setPreferredSize(new Dimension(70, 70));
flipBoardButton.setFont(new Font("SansSerif", Font.BOLD, 40));
flipBoardButton.setBackground(new Color(0x5500ff));
flipBoardButton.setForeground(Color.WHITE);
flipBoardButton.setFocusPainted(false);
buttonRow.add(resignButton);
buttonRow.add(drawButton);
buttonRow.add(flipBoardButton);
chessPanel.add(buttonRow, BorderLayout.SOUTH);
return chessPanel;
} }
public JPanel statsPanel() { public JPanel statsPanel() {
JPanel statsPanel = new JPanel(new BorderLayout()); JPanel statsPanel = new JPanel(new BorderLayout());

View File

@ -17,7 +17,8 @@ public class MainGui {
frame = new JFrame("Chess - Hauptmenü"); frame = new JFrame("Chess - Hauptmenü");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1600, 1000); frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setUndecorated(false);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
//Haupt-Panel mit GridBagLayout //Haupt-Panel mit GridBagLayout

View File

@ -47,7 +47,8 @@ public class PgnGui {
public JFrame mainFrame() { public JFrame mainFrame() {
JFrame frame = new JFrame(); JFrame frame = new JFrame();
frame.setSize(1600, 1000); frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setUndecorated(false);
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
frame.add(mainPanel()); frame.add(mainPanel());