From 12d66335f6d9faf2f0a546b68898e26ec3c25c3c Mon Sep 17 00:00:00 2001 From: Vickvick2002 Date: Fri, 3 Jan 2025 13:40:46 +0100 Subject: [PATCH] =?UTF-8?q?Klasse=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PR2/HitoriSpiel/GUI/GameBoardView.java | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 Hitori/src/main/java/PR2/HitoriSpiel/GUI/GameBoardView.java diff --git a/Hitori/src/main/java/PR2/HitoriSpiel/GUI/GameBoardView.java b/Hitori/src/main/java/PR2/HitoriSpiel/GUI/GameBoardView.java deleted file mode 100644 index 2ce49b6..0000000 --- a/Hitori/src/main/java/PR2/HitoriSpiel/GUI/GameBoardView.java +++ /dev/null @@ -1,51 +0,0 @@ -package PR2.HitoriSpiel.GUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -public class GameBoardView extends JPanel { - private final JButton[][] cells; // Spielfeld als Buttons - - public GameBoardView(int rows, int cols) { - this.setLayout(new GridLayout(rows, cols)); // Grid-Layout für das Spielfeld - cells = new JButton[rows][cols]; - - // Spielfeld-Buttons initialisieren - for (int row = 0; row < rows; row++) { - for (int col = 0; col < cols; col++) { - cells[row][col] = new JButton(); - cells[row][col].setBackground(Color.LIGHT_GRAY); - int finalRow = row; - int finalCol = col; - - // ActionListener für Button-Klick - cells[row][col].addActionListener(e -> toggleCellColor(finalRow, finalCol)); - this.add(cells[row][col]); - } - } - } - - // Methode zum Umschalten der Zellenfarbe - private void toggleCellColor(int row, int col) { - JButton button = cells[row][col]; - if (button.getBackground() == Color.LIGHT_GRAY) { - button.setBackground(Color.BLACK); - } else if (button.getBackground() == Color.BLACK) { - button.setBackground(Color.WHITE); - } else { - button.setBackground(Color.LIGHT_GRAY); - } - } - - // Methode zum Aktualisieren des Spielfelds (optional) - public void render(int[][] board) { - for (int row = 0; row < board.length; row++) { - for (int col = 0; col < board[row].length; col++) { - cells[row][col].setText(String.valueOf(board[row][col])); - } - } - } -} -