From 101b5e7d1982710dab2195b22bb8921e9c7e3b8b Mon Sep 17 00:00:00 2001 From: dstuck Date: Wed, 25 Jun 2025 05:33:58 +0200 Subject: [PATCH] fix --- .../de/mannheim/th/chess/ui/SpielFrame.java | 98 +++++++++---------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/src/main/java/de/mannheim/th/chess/ui/SpielFrame.java b/src/main/java/de/mannheim/th/chess/ui/SpielFrame.java index 4d7c34f..fdca8ff 100644 --- a/src/main/java/de/mannheim/th/chess/ui/SpielFrame.java +++ b/src/main/java/de/mannheim/th/chess/ui/SpielFrame.java @@ -211,57 +211,55 @@ public class SpielFrame extends JFrame { } } - /** - * Sets the default background color for the buttons in the grid. - */ - private void setDefaultBackground() { - int counter = 8; - for (int i = 0; i < 64; i++) { - JButton b = buttons.get(i); - if ((i / 8 + i % 8) % 2 == 0) { - // logger.info("Helles Feld erstellt." + i); - b.setBackground(new Color(90, 90, 90)); - - - } else { - // logger.info("Dunkles Feld erstellt." + i); - b.setBackground(new Color(65, 65, 65)); - } - - if(i % 8 == 0) { - b.setHorizontalAlignment(SwingConstants.CENTER); - b.setVerticalAlignment(SwingConstants.CENTER); + /** + * Sets the default background color for the buttons in the grid. + */ + private void setDefaultBackground() { + int counter = 8; + for (int i = 0; i < 64; i++) { + JButton b = buttons.get(i); + if ((i / 8 + i % 8) % 2 == 0) { + // logger.info("Helles Feld erstellt." + i); + b.setBackground(new Color(90, 90, 90)); - b.setHorizontalTextPosition(SwingConstants.LEFT); // Text rechts vom Icon - b.setVerticalTextPosition(SwingConstants.BOTTOM); - - b.setIconTextGap(5); - - b.setText(String.valueOf(counter)+b.getText()); - counter--; - } - } - - - - char buchstabe = 'a'; - for(int j=0;j<8;j++) { - JButton button = buttons.get(mirrowedGrid(j)); - - button.setHorizontalAlignment(SwingConstants.CENTER); - button.setVerticalAlignment(SwingConstants.CENTER); + } else { + // logger.info("Dunkles Feld erstellt." + i); + b.setBackground(new Color(65, 65, 65)); + } - button.setHorizontalTextPosition(SwingConstants.RIGHT); // Text rechts vom Icon - button.setVerticalTextPosition(SwingConstants.BOTTOM); - - button.setIconTextGap(5); - - button.setText(String.valueOf(buchstabe)); - buchstabe++; - } - - } - /** + if (i % 8 == 0) { + b.setHorizontalAlignment(SwingConstants.CENTER); + b.setVerticalAlignment(SwingConstants.CENTER); + + b.setHorizontalTextPosition(SwingConstants.LEFT); // Text rechts vom Icon + b.setVerticalTextPosition(SwingConstants.BOTTOM); + + b.setIconTextGap(5); + + b.setText(String.valueOf(counter) + b.getText()); + counter--; + } + } + + char buchstabe = 'a'; + for (int j = 0; j < 8; j++) { + JButton button = buttons.get(mirrowedGrid(j)); + + button.setHorizontalAlignment(SwingConstants.CENTER); + button.setVerticalAlignment(SwingConstants.CENTER); + + button.setHorizontalTextPosition(SwingConstants.RIGHT); // Text rechts vom Icon + button.setVerticalTextPosition(SwingConstants.BOTTOM); + + button.setIconTextGap(5); + + button.setText(String.valueOf(buchstabe)); + buchstabe++; + } + + } + + /** * Sets the to default buttons */ public void setDefaultButtons() { @@ -322,11 +320,9 @@ public class SpielFrame extends JFrame { break; case finished: - clearButtons(); break; case gameEnd: - break; default: