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,19 +135,52 @@ 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; // --- Eröffnungslabel oben ---
board.weightx = 0.7; openingLabel = new JLabel("Eröffnung: unbekannt", SwingConstants.CENTER);
board.weighty = 1.0; openingLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
board.insets = new Insets(0, 0, 0, 0); openingLabel.setForeground(Color.WHITE);
//oben, links, unten, rechts openingLabel.setOpaque(true);
board.fill = GridBagConstraints.BOTH; openingLabel.setBackground(new Color(0x283655));
chessPanel.add(panel); openingLabel.setPreferredSize(new Dimension(800, 50));
// Button unten rechts chessPanel.add(openingLabel, BorderLayout.NORTH);
// --- Board in ein zentriertes Panel mit fixer Größe ---
JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
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 = new JButton("⇵");
flipBoardButton.setPreferredSize(new Dimension(70, 70)); flipBoardButton.setPreferredSize(new Dimension(70, 70));
flipBoardButton.setFont(new Font("SansSerif", Font.BOLD, 40)); flipBoardButton.setFont(new Font("SansSerif", Font.BOLD, 40));
@ -150,19 +188,16 @@ public class GameGui {
flipBoardButton.setForeground(Color.WHITE); flipBoardButton.setForeground(Color.WHITE);
flipBoardButton.setFocusPainted(false); flipBoardButton.setFocusPainted(false);
GridBagConstraints btn = new GridBagConstraints(); buttonRow.add(resignButton);
btn.gridx = 0; buttonRow.add(drawButton);
btn.gridy = 1; buttonRow.add(flipBoardButton);
btn.weightx = 0.0;
btn.weighty = 0.0;
btn.anchor = GridBagConstraints.SOUTHEAST;
btn.insets = new Insets(10, 0, 0, 0);
chessPanel.add(flipBoardButton, btn); chessPanel.add(buttonRow, BorderLayout.SOUTH);
return chessPanel; return chessPanel;
} }
public JPanel statsPanel() { public JPanel statsPanel() {
JPanel statsPanel = new JPanel(new BorderLayout()); JPanel statsPanel = new JPanel(new BorderLayout());
statsPanel.setBackground(new Color(0x0d1b2a)); statsPanel.setBackground(new Color(0x0d1b2a));

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());