Compare commits

..

No commits in common. "d0c267f7b071095958c9074499c9423f18d9a5c3" and "5770d13cdc7bb6ceef3a6d2fcf298973977a6816" have entirely different histories.

11 changed files with 91 additions and 328 deletions

View File

@ -29,7 +29,7 @@ public class CreativeController {
map.put("WHITE_ROOK", 'R');
map.put("WHITE_BISHOP", 'B');
map.put("WHITE_KNIGHT", 'N');
map.put("WHITE_PAWN", 'P');
map.put("WHITE_PAWN", 'P');
return map;
}

View File

@ -11,12 +11,11 @@ import javax.swing.BorderFactory;
import com.github.bhlangonijr.chesslib.game.Game;
import de.hs_mannheim.informatik.chess.model.ChessEngine;
import de.hs_mannheim.informatik.chess.model.GameMode;
import de.hs_mannheim.informatik.chess.model.MoveDTO;
import de.hs_mannheim.informatik.chess.model.PieceDTO;
import de.hs_mannheim.informatik.chess.model.Timer;
import de.hs_mannheim.informatik.chess.model.BoardDTO;
import de.hs_mannheim.informatik.chess.view.GameGui;
import de.hs_mannheim.informatik.chess.view.MainGui;
public class GameController {
GameGui gui;
@ -26,24 +25,13 @@ public class GameController {
private boolean gameOver = false;
private int selectedRow = -1, selectedCol = -1;
private List<int[]> highlightedFields = new ArrayList<>();
private GameMode gameMode;
public GameController(GameGui gui, ChessEngine engine, GameEndCallback callback, GameMode gameMode) {
this(gui, engine, callback); // ruft anderen Konstruktor auf
this.gameMode = gameMode;
if (gameMode != null) {
engine.initTimers(gameMode.minutes, gameMode.incrementSeconds);
time();
}
}
// Für Creative/PGN-Mode (ohne Zeit)
public GameController(GameGui gui, ChessEngine engine, GameEndCallback callback) {
this.gui = gui;
this.engine = engine;
this.callback = callback;
this.gameMode = null;
// KEINE Timer initialisieren
engine.initTimers(3, 0);
time();
initListeners();
updateGuiBoard();
}
@ -138,6 +126,7 @@ public class GameController {
// --- AUFGEBEN-BUTTON ---
gui.getResignButton().addActionListener(e -> {
if (gameOver) return;
int answer = javax.swing.JOptionPane.showConfirmDialog(
null,
"Willst du wirklich aufgeben?",
@ -148,14 +137,16 @@ public class GameController {
gameOver = true;
String winner = engine.getCurrentPlayer().equals("WHITE") ? "SCHWARZ" : "WEIß";
gui.displayMessage(winner + " gewinnt durch Aufgabe!");
if (engine.getWhiteTimer() != null) engine.getWhiteTimer().stop();
if (engine.getBlackTimer() != null) engine.getBlackTimer().stop();
engine.getWhiteTimer().stop();
engine.getBlackTimer().stop();
askForRestart();
}
});
// --- PATT-/REMIS-BUTTON ---
gui.getDrawButton().addActionListener(e -> {
if (gameOver) return;
int answer = javax.swing.JOptionPane.showConfirmDialog(
null,
"Remis anbieten? (Das Spiel endet sofort unentschieden)",
@ -165,8 +156,8 @@ public class GameController {
if (answer == javax.swing.JOptionPane.YES_OPTION) {
gameOver = true;
gui.displayMessage("Remis! (durch Einigung)");
if (engine.getWhiteTimer() != null) engine.getWhiteTimer().stop();
if (engine.getBlackTimer() != null) engine.getBlackTimer().stop();
engine.getWhiteTimer().stop();
engine.getBlackTimer().stop();
askForRestart();
}
});
@ -288,8 +279,6 @@ public class GameController {
updateGuiBoard();
gui.updateMoveList(engine.getMoveListStringsGrouped());
// ---- HIER ist die Matt/Patt/Remis-Prüfung ----
if (engine.isMated()) {
@ -316,25 +305,12 @@ public class GameController {
}
private void switchTimers() {
GameMode mode = engine.getGameMode();
Timer whiteTimer = engine.getWhiteTimer();
Timer blackTimer = engine.getBlackTimer();
// Wenn KEIN Modus (also kein Timer): NICHTS machen!
if (mode == null || whiteTimer == null || blackTimer == null) return;
if (engine.getCurrentPlayer().equals("WHITE")) {
if (mode.incrementSeconds > 0) {
blackTimer.addSeconds(mode.incrementSeconds);
}
blackTimer.stop();
whiteTimer.start();
engine.getBlackTimer().stop();
engine.getWhiteTimer().start();
} else {
if (mode.incrementSeconds > 0) {
whiteTimer.addSeconds(mode.incrementSeconds);
}
whiteTimer.stop();
blackTimer.start();
engine.getWhiteTimer().stop();
engine.getBlackTimer().start();
}
}

View File

@ -5,7 +5,6 @@ import de.hs_mannheim.informatik.chess.view.PgnGui;
import de.hs_mannheim.informatik.chess.view.PgnSelectionGui;
import de.hs_mannheim.informatik.chess.view.CreativeGui;
import de.hs_mannheim.informatik.chess.view.GameGui;
import de.hs_mannheim.informatik.chess.view.GameModeSelector;
import java.io.IOException;
import java.util.List;
@ -16,7 +15,6 @@ import javax.swing.JOptionPane;
import com.github.bhlangonijr.chesslib.game.Game;
import de.hs_mannheim.informatik.chess.model.ChessEngine;
import de.hs_mannheim.informatik.chess.model.GameMode;
public class MainController {
private MainGui mainGui;
@ -30,11 +28,9 @@ public class MainController {
}
private void startNormalMode() {
GameMode mode = GameModeSelector.selectGameMode();
mainGui.close();
GameGui gameGui = new GameGui();
ChessEngine engine = new ChessEngine(mode);
ChessEngine engine = new ChessEngine();
GameEndCallback callback = new GameEndCallback() {
public void onNewGameRequested() {
startNormalMode();
@ -43,7 +39,7 @@ public class MainController {
new MainController();
}
};
new GameController(gameGui, engine, callback,mode);
new GameController(gameGui, engine, callback);
}
private void startCreativeMode() {
@ -51,25 +47,6 @@ public class MainController {
CreativeGui creativegui = new CreativeGui();
ChessEngine engine = new ChessEngine();
new CreativeController(creativegui, engine);
creativegui.setStartGameCallback(fen -> {
// 1. Modus-Auswahl-Dialog zeigen!
GameMode mode = GameModeSelector.selectGameMode(); // (Dialog, wie beim Normal Mode)
if (mode == null) return; // User hat abgebrochen → nichts machen
ChessEngine newEngine = new ChessEngine(mode); // Engine mit Modus (Timer)
newEngine.setPositionFromFEN(fen);
GameGui gameGui = new GameGui();
GameEndCallback callback = new GameEndCallback() {
public void onNewGameRequested() { startCreativeMode(); }
public void onReturnToMenu() { new MainController(); }
};
new GameController(gameGui, newEngine, callback, mode); // mit Timer/ohne je nach Modus
creativegui.close();
});
}
private void startLoadGameMode() {
@ -91,6 +68,5 @@ public class MainController {
JOptionPane.showMessageDialog(null, "Fehler beim Laden der PGN-Datei:\n" + ex.getMessage());
}
}
mainGui.close();
}
}

View File

@ -65,8 +65,7 @@ public class PgnController {
public void updateGuiBoard() {
BoardDTO board = engine.getBoardAsDTO();
gui.updateBoard(board);
gui.updateMoveList(engine.getMoveListStringsGrouped());
gui.setOpeningLabel(engine.getOpeningName());
gui.updateMoveList(engine.getMoveListStringsGrouped());
}
private void resetFieldBackground(int row, int col) {

View File

@ -25,30 +25,18 @@ import com.github.bhlangonijr.chesslib.Side;
public class ChessEngine {
private Board board;
private List<Move> moves = new ArrayList<>();
private String initialFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
private static final Logger logger = Logger.getLogger(ChessEngine.class.getName());
private int currentMoveIndex = 0;
private Timer whiteTimer;
private Timer blackTimer;
private final GameMode mode;
private Opening detectedOpening = null;
public ChessEngine() {
this.mode = null;
public ChessEngine() {
logging();
board = new Board();
}
public ChessEngine(GameMode mode) {
this.mode = mode;
whiteTimer = new Timer(mode.minutes, mode.seconds);
blackTimer = new Timer(mode.minutes, mode.seconds);
logging();
board = new Board();
}
public boolean move(MoveDTO move) {
String from = "" + (char)('A' + move.getFromCol()) + (8 - move.getFromRow());
String to = "" + (char)('A' + move.getToCol()) + (8 - move.getToRow());
@ -200,9 +188,9 @@ public class ChessEngine {
}
public void setPositionToMoveIndex(int idx) {
logger.info("Setze Board auf Zug-Index: " + idx);
// Neues Board erzeugen
logger.info("Setze Board auf Zug-Index: " + idx);
board = new Board();
board.loadFromFen(initialFen); // Statt new Board() -> initialFen!
for (int i = 0; i < idx; i++) {
board.doMove(moves.get(i));
}
@ -211,6 +199,7 @@ public class ChessEngine {
String playedMovesUci = movesToUciString(moves.subList(0, idx));
detectedOpening = Opening.detect(playedMovesUci);
}
public int getCurrentMoveIndex() {
logger.info("Hole aktuellen Zug-Index: " + currentMoveIndex);
return currentMoveIndex;
@ -231,7 +220,6 @@ public class ChessEngine {
public void setPositionFromFEN(String fen) {
board.loadFromFen(fen);
initialFen = fen;
}
@ -275,7 +263,7 @@ public class ChessEngine {
logger.info("ChessEngine wurde initialisiert.");
}
public List<Game> loadGamesFromPgn(String path) throws IOException {
PgnHolder pgnHolder = new PgnHolder(path);
@ -423,17 +411,6 @@ public class ChessEngine {
}
public Timer getWhiteTimer() { return whiteTimer; }
public Timer getBlackTimer() { return blackTimer; }
public GameMode getGameMode() {
// TODO Auto-generated method stub
return mode;
}
public Timer getBlackTimer() { return blackTimer; }
}

View File

@ -1,26 +0,0 @@
package de.hs_mannheim.informatik.chess.model;
public enum GameMode {
CLASSIC(3, 0, 0),
RAPID(5, 0, 0),
BULLET(1, 0, 10); // 1 Minute + 10 Sek Inkrement
public final int minutes;
public final int seconds;
public final int incrementSeconds;
GameMode(int minutes, int seconds, int incrementSeconds) {
this.minutes = minutes;
this.seconds = seconds;
this.incrementSeconds = incrementSeconds;
}
@Override
public String toString() {
return switch (this) {
case CLASSIC -> "3 Minuten (klassisch)";
case RAPID -> "5 Minuten (rapid)";
case BULLET -> "1 Minute + 10 Sek Inkrement";
};
}
}

View File

@ -56,10 +56,6 @@ public class Timer {
public int getSecondsLeft() {
return secondsLeft;
}
public void addSeconds(int seconds) {
this.secondsLeft += seconds;
}
}

View File

@ -5,11 +5,6 @@ import java.awt.*;
import java.util.HashMap;
public class CreativeGui {
public interface StartGameCallback {
void onStartGame(String fen);
}
private boolean isFlipped = false;
private JFrame frame;
@ -18,12 +13,6 @@ public class CreativeGui {
private JTextField fenField;
private JButton updateBtn;
private JButton flipBoardButton;
private boolean closedByUser = true;
private StartGameCallback startGameCallback;
private JButton startGameButton;
public static final HashMap<String, String> UNICODE_MAP = new HashMap<String, String>() {{
put("BLACK_KING", "\u265A"); put("BLACK_QUEEN", "\u265B");
@ -52,7 +41,7 @@ public class CreativeGui {
// LINKS: chessPanel (Board+Toolbars)
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.7;
gbc.weightx = 0.6;
gbc.weighty = 1.0;
gbc.insets = new Insets(5, 5, 5, 0);
gbc.fill = GridBagConstraints.BOTH;
@ -61,21 +50,12 @@ public class CreativeGui {
// RECHTS: FEN & Optionen
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 0.3;
gbc.weightx = 0.4;
gbc.weighty = 1.0;
gbc.insets = new Insets(5, 0, 5, 5);
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(fenPanel(), gbc);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
if (closedByUser) {
new de.hs_mannheim.informatik.chess.controller.MainController();
}
}
});
frame.setContentPane(mainPanel);
frame.setVisible(true);
}
@ -92,7 +72,7 @@ public class CreativeGui {
btn.setFocusPainted(false);
btn.setPreferredSize(new Dimension(70, 70));
btn.setBackground(white ? LIGHT : DARK);
btn.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
btn.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 0));
String key = prefix + type;
btn.addActionListener(e -> selectedPiece = key);
panel.add(btn);
@ -125,76 +105,47 @@ public class CreativeGui {
}
private JPanel chessPanel() {
JPanel chessPanel = new JPanel(new BorderLayout());
JPanel chessPanel = new JPanel(new GridBagLayout());
chessPanel.setBackground(new Color(0x1b263b));
GridBagConstraints gbc = new GridBagConstraints();
// Board UND Toolbars in EINEM Panel, damit sie linksbündig mit dem Brett starten!
JPanel boardAndToolbars = new JPanel(new BorderLayout());
boardAndToolbars.setOpaque(false);
// Toolbar oben
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
chessPanel.add(toolbarPanel(false), gbc);
// Toolbar Schwarz (oben)
JPanel blackToolbar = toolbarPanel(false);
boardAndToolbars.add(blackToolbar, BorderLayout.NORTH);
// Board
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.BOTH;
chessPanel.add(boardPanel(), gbc);
// Board (zentriert im Panel)
JPanel board = boardPanel();
boardAndToolbars.add(board, BorderLayout.CENTER);
// Toolbar unten
gbc.gridx = 0;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
chessPanel.add(toolbarPanel(true), gbc);
// Toolbar Weiß (unten)
JPanel whiteToolbar = toolbarPanel(true);
boardAndToolbars.add(whiteToolbar, BorderLayout.SOUTH);
// Board+Toolbars mittig in einem Panel mit FlowLayout, damit sie zentriert sind
JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
centerPanel.setOpaque(false);
centerPanel.add(boardAndToolbars);
// Drehknopf
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);
blackToolbar.setPreferredSize(new Dimension(0, 70)); // 70 px hoch
whiteToolbar.setPreferredSize(new Dimension(0, 70));
// Dynamisch skalieren wie gehabt
centerPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
int totalHeight = centerPanel.getHeight();
int totalWidth = centerPanel.getWidth();
int toolbarHeight = blackToolbar.getPreferredSize().height + whiteToolbar.getPreferredSize().height;
// Falls Toolbars keine PrefSize haben, nimm getHeight()
if (toolbarHeight == 0) toolbarHeight = blackToolbar.getHeight() + whiteToolbar.getHeight();
int boardMaxHeight = totalHeight - toolbarHeight;
int size = Math.min(totalWidth, boardMaxHeight);
board.setPreferredSize(new Dimension(size, size));
board.revalidate();
}
});
chessPanel.add(centerPanel, BorderLayout.CENTER);
// Drehknopf rechts, schön mittig
JPanel eastPanel = new JPanel();
eastPanel.setOpaque(false);
eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS));
eastPanel.add(Box.createVerticalGlue());
eastPanel.add(flipBoardButton = createFlipButton());
eastPanel.add(Box.createVerticalGlue());
chessPanel.add(eastPanel, BorderLayout.EAST);
// Buffer links, wenn du willst
chessPanel.add(Box.createRigidArea(new Dimension(40, 0)), BorderLayout.WEST);
GridBagConstraints btn = new GridBagConstraints();
btn.gridx = 0;
btn.gridy = 2;
btn.weightx = 0.0;
btn.weighty = 0.0;
btn.anchor = GridBagConstraints.EAST;
btn.insets = new Insets(5, 0, 0, 0);
chessPanel.add(flipBoardButton, btn);
return chessPanel;
}
// Flip-Knopf Builder, damit dus an mehreren Stellen nutzen kannst:
private JButton createFlipButton() {
JButton btn = new JButton("⇵");
btn.setPreferredSize(new Dimension(70, 70));
btn.setFont(new Font("SansSerif", Font.BOLD, 40));
btn.setBackground(new Color(0x5500ff));
btn.setForeground(Color.WHITE);
btn.setFocusPainted(false);
return btn;
}
private JPanel fenPanel() {
JPanel panel = new JPanel();
@ -209,21 +160,7 @@ public class CreativeGui {
updateBtn = new JButton("Update Board");
updateBtn.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(updateBtn);
startGameButton = new JButton("🟢 Partie starten");
startGameButton.setAlignmentX(Component.CENTER_ALIGNMENT);
startGameButton.setBackground(new Color(0x218838));
startGameButton.setForeground(Color.WHITE);
panel.add(startGameButton);
startGameButton.addActionListener(e -> {
if (startGameCallback != null) {
setClosedByUser(false);
startGameCallback.onStartGame(getFenText());
}
});
return panel;
}
// Für Controller
@ -234,21 +171,8 @@ public class CreativeGui {
public JButton getUpdateButton() { return updateBtn; }
public void setSelectedPiece(String piece) { selectedPiece = piece; }
public String getSelectedPiece() { return selectedPiece; }
public void setClosedByUser(boolean b) {
this.closedByUser = b;
}
public JButton getStartGameButton() { return startGameButton; }
public void setStartGameCallback(StartGameCallback callback) {
this.startGameCallback = callback;
}
public boolean isFlipped() { return isFlipped; }
public void setFlipped(boolean f) { isFlipped = f; }
public JButton getFlipBoardButton() { return flipBoardButton; }
public void close() {
frame.dispose();
}
}

View File

@ -238,7 +238,6 @@ public class GameGui {
btnNext.setBackground(new Color(0x212529)); btnNext.setForeground(Color.WHITE);
btnLast.setBackground(new Color(0x212529)); btnLast.setForeground(Color.WHITE);
btnSave.setBackground(new Color(0x218838)); btnSave.setForeground(Color.WHITE);
buttonPanel.add(btnFirst);
buttonPanel.add(btnPrev);
buttonPanel.add(btnNext);
@ -254,8 +253,8 @@ public class GameGui {
JPanel panel = new JPanel(new GridLayout(2, 1));
panel.setBackground(new Color(0x0d1b2a));
whiteTimerLabel = new JLabel("Weiß: --:--", SwingConstants.CENTER);
blackTimerLabel = new JLabel("Schwarz: --:--", SwingConstants.CENTER);
whiteTimerLabel = new JLabel("Weiß: 03:00", SwingConstants.CENTER);
blackTimerLabel = new JLabel("Schwarz: 03:00", SwingConstants.CENTER);
whiteTimerLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
whiteTimerLabel.setForeground(Color.WHITE);

View File

@ -1,23 +0,0 @@
package de.hs_mannheim.informatik.chess.view;
import javax.swing.*;
import de.hs_mannheim.informatik.chess.model.GameMode;
public class GameModeSelector {
public static GameMode selectGameMode() {
GameMode[] options = GameMode.values();
GameMode selected = (GameMode) JOptionPane.showInputDialog(
null,
"Wähle den Spielmodus:",
"Spielmodus auswählen",
JOptionPane.QUESTION_MESSAGE,
null,
options,
GameMode.CLASSIC
);
return selected != null ? selected : GameMode.CLASSIC;
}
}

View File

@ -3,7 +3,6 @@ package de.hs_mannheim.informatik.chess.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@ -11,7 +10,6 @@ import java.awt.GridLayout;
import java.awt.Insets;
import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
@ -35,8 +33,6 @@ public class PgnGui {
JButton btnNext = new JButton(">");
JButton btnLast = new JButton(">|");
private JLabel openingLabel;
Color LIGHT = new Color(0xe0e1dd);
Color DARK = new Color(0x778da9);
@ -58,12 +54,6 @@ public class PgnGui {
frame.setDefaultCloseOperation(2);
frame.setVisible(true);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
new de.hs_mannheim.informatik.chess.controller.MainController();
}
});
return frame;
}
@ -134,57 +124,37 @@ public class PgnGui {
return boardPanel;
}
public JPanel chessPanel(JPanel boardPanel) {
JPanel chessPanel = new JPanel(new BorderLayout());
chessPanel.setBackground(new Color(0x1b263b));
public JPanel chessPanel(JPanel panel) {
JPanel chessPanel = new JPanel(new GridBagLayout());
GridBagConstraints board = new GridBagConstraints();
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);
// --- 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);
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);
// --- Board in ein zentriertes Panel mit fixer Größe ---
JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
centerPanel.setOpaque(false);
centerPanel.add(boardPanel);
centerPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
int size = Math.min(centerPanel.getWidth(), centerPanel.getHeight());
boardPanel.setPreferredSize(new Dimension(size, size));
boardPanel.revalidate();
}
});
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));
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(flipBoardButton);
chessPanel.add(buttonRow, BorderLayout.SOUTH);
return chessPanel;
chessPanel.add(flipBoardButton, btn);
return chessPanel;
}
public JPanel statsPanel() {
@ -270,11 +240,6 @@ public class PgnGui {
this.isFlipped = flipped;
}
public void setOpeningLabel(String text) {
openingLabel.setText("Eröffnung: " + text);
}
public JButton getBtnFirst() { return btnFirst; }
public JButton getBtnPrev() { return btnPrev; }
public JButton getBtnNext() { return btnNext; }