diff --git a/schach/src/main/java/de/hs_mannheim/informatik/chess/view/GameGui.java b/schach/src/main/java/de/hs_mannheim/informatik/chess/view/GameGui.java index bda4eee..3cbda96 100644 --- a/schach/src/main/java/de/hs_mannheim/informatik/chess/view/GameGui.java +++ b/schach/src/main/java/de/hs_mannheim/informatik/chess/view/GameGui.java @@ -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; @@ -98,7 +115,7 @@ public class GameGui { boardPanel.setBackground(new Color(0x1b263b)); return boardPanel; } - + public JPanel chessPanel(JPanel panel) { JPanel chessPanel = new JPanel(new GridBagLayout()); GridBagConstraints board = new GridBagConstraints(); @@ -145,6 +162,7 @@ public class GameGui { return statsPanel; } + public void updateMoveList(List moves) { moveListPanel.removeAll(); for (String move : moves) {