Changed frame size for all Gui and reworked chessPanel in GameGui
parent
66a8c1a51d
commit
35b7d9aa9a
|
@ -30,7 +30,8 @@ public class CreativeGui {
|
|||
public CreativeGui() {
|
||||
frame = new JFrame("Creative Mode");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setSize(1600, 1200);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setUndecorated(false);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
|
|
|
@ -7,9 +7,12 @@ import java.awt.Font;
|
|||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import java.awt.Insets;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
|
@ -31,6 +34,7 @@ public class GameGui {
|
|||
|
||||
private JLabel whiteTimerLabel;
|
||||
private JLabel blackTimerLabel;
|
||||
private JLabel openingLabel;
|
||||
|
||||
private JButton btnFirst = new JButton("|<");
|
||||
private JButton btnPrev = new JButton("<");
|
||||
|
@ -54,7 +58,8 @@ public class GameGui {
|
|||
|
||||
public JFrame mainFrame() {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setSize(1600, 1000);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setUndecorated(false);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.add(mainPanel());
|
||||
|
||||
|
@ -130,19 +135,52 @@ public class GameGui {
|
|||
return boardPanel;
|
||||
}
|
||||
|
||||
public JPanel chessPanel(JPanel panel) {
|
||||
JPanel chessPanel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints board = new GridBagConstraints();
|
||||
public JPanel chessPanel(JPanel boardPanel) {
|
||||
JPanel chessPanel = new JPanel(new BorderLayout());
|
||||
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
|
||||
|
||||
// --- Eröffnungslabel oben ---
|
||||
openingLabel = new JLabel("Eröffnung: unbekannt", SwingConstants.CENTER);
|
||||
openingLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
|
||||
openingLabel.setForeground(Color.WHITE);
|
||||
openingLabel.setOpaque(true);
|
||||
openingLabel.setBackground(new Color(0x283655));
|
||||
openingLabel.setPreferredSize(new Dimension(800, 50));
|
||||
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.setPreferredSize(new Dimension(70, 70));
|
||||
flipBoardButton.setFont(new Font("SansSerif", Font.BOLD, 40));
|
||||
|
@ -150,19 +188,16 @@ public class GameGui {
|
|||
flipBoardButton.setForeground(Color.WHITE);
|
||||
flipBoardButton.setFocusPainted(false);
|
||||
|
||||
GridBagConstraints btn = new GridBagConstraints();
|
||||
btn.gridx = 0;
|
||||
btn.gridy = 1;
|
||||
btn.weightx = 0.0;
|
||||
btn.weighty = 0.0;
|
||||
btn.anchor = GridBagConstraints.SOUTHEAST;
|
||||
btn.insets = new Insets(10, 0, 0, 0);
|
||||
buttonRow.add(resignButton);
|
||||
buttonRow.add(drawButton);
|
||||
buttonRow.add(flipBoardButton);
|
||||
|
||||
chessPanel.add(flipBoardButton, btn);
|
||||
chessPanel.add(buttonRow, BorderLayout.SOUTH);
|
||||
|
||||
return chessPanel;
|
||||
}
|
||||
|
||||
|
||||
public JPanel statsPanel() {
|
||||
JPanel statsPanel = new JPanel(new BorderLayout());
|
||||
statsPanel.setBackground(new Color(0x0d1b2a));
|
||||
|
|
|
@ -17,7 +17,8 @@ public class MainGui {
|
|||
|
||||
frame = new JFrame("Chess - Hauptmenü");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(1600, 1000);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setUndecorated(false);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
//Haupt-Panel mit GridBagLayout
|
||||
|
|
|
@ -47,7 +47,8 @@ public class PgnGui {
|
|||
|
||||
public JFrame mainFrame() {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setSize(1600, 1000);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setUndecorated(false);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.add(mainPanel());
|
||||
|
||||
|
|
Loading…
Reference in New Issue