From d9311a38db7664ba5e1491f72fbf5e91bf6c63b6 Mon Sep 17 00:00:00 2001 From: lov3b Date: Tue, 1 Mar 2022 19:36:16 +0100 Subject: [PATCH] =?UTF-8?q?Br=C3=B6t=20ut=20drawSquares?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schack/Board.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/schack/Board.java b/src/schack/Board.java index 03fa6e1..0da936c 100644 --- a/src/schack/Board.java +++ b/src/schack/Board.java @@ -17,21 +17,26 @@ public class Board extends JPanel { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; + drawSquares(g2); + } + + private void drawSquares(Graphics2D g2) { g2.scale(100, 100); g2.setBackground(Color.WHITE); g2.setColor(Color.BLACK); for (int i = 0; i < 8; i += 2) { for (int j = 0; j < 8; j += 2) { - g.fillRect(i, j, 1, 1); + g2.fillRect(i, j, 1, 1); } } for (int i = 1; i < 8; i += 2) { for (int j = 1; j < 8; j += 2) { - g.fillRect(i, j, 1, 1); + g2.fillRect(i, j, 1, 1); } } + } }