New flip button in GameGui

Quicksave
Justin 2025-06-19 21:24:35 +02:00
parent 241a532327
commit 1167b54260
1 changed files with 30 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@ -20,6 +21,8 @@ import de.hs_mannheim.informatik.chess.model.PieceDTO;
public class GameGui {
private JLabel[][] fields = new JLabel[8][8];
private JButton flipBoardButton;
private boolean isFlipped = false;
public GameGui(){
mainFrame();
@ -101,6 +104,25 @@ public class GameGui {
//oben, links, unten, rechts
board.fill = GridBagConstraints.BOTH;
chessPanel.add(panel);
// Button unten rechts
flipBoardButton = new JButton("\u21bb"); // 🔄
flipBoardButton.setPreferredSize(new Dimension(50, 50));
flipBoardButton.setBackground(new Color(0x778da9));
flipBoardButton.setForeground(Color.WHITE);
flipBoardButton.setFocusPainted(false);
flipBoardButton.setFont(new Font("Serif", Font.BOLD, 25));
flipBoardButton.setToolTipText("Brett drehen");
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, 10);
chessPanel.add(flipBoardButton, btn);
return chessPanel;
}
@ -114,6 +136,14 @@ public class GameGui {
return fields[row][col];
}
public JButton getFlipBoardButton() {
return flipBoardButton;
}
public boolean isFlipped() {
return isFlipped;
}
public void updateBoard(BoardDTO boardDTO) {
PieceDTO[][] board = boardDTO.getBoard();
for (int row = 0; row < 8; row++) {