New initFields method in GameGui

Quicksave
Justin 2025-06-20 02:51:11 +02:00
parent 7394548cc5
commit db7e2a9f5a
1 changed files with 20 additions and 2 deletions

View File

@ -32,6 +32,7 @@ public class GameGui {
private JScrollPane moveListScroll;
public GameGui(){
initFields();
mainFrame();
}
@ -47,6 +48,22 @@ public class GameGui {
return frame;
}
private void initFields() {
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
JLabel label = new JLabel("", SwingConstants.CENTER);
label.setOpaque(true);
label.setFont(new Font("Serif", Font.BOLD, 40));
if ((row + col) % 2 == 0) {
label.setBackground(new Color(0x778da9));
} else {
label.setBackground(new Color(0xe0e1dd));
}
fields[row][col] = label;
}
}
}
public JPanel mainPanel() {
JPanel mainPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
@ -59,7 +76,7 @@ public class GameGui {
gbc.insets = new Insets(5, 5, 5, 0);
//oben, links, unten, rechts
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(chessPanel(boardPanel()),gbc);
mainPanel.add(chessPanel(boardPanel()), gbc);
// Rechts (Stats)
gbc.gridx = 1;
@ -145,6 +162,7 @@ public class GameGui {
return statsPanel;
}
public void updateMoveList(List<String> moves) {
moveListPanel.removeAll();
for (String move : moves) {