cleanup
dstuck 2025-06-25 05:33:58 +02:00
parent 043e8b5090
commit 101b5e7d19
1 changed files with 47 additions and 51 deletions

View File

@ -211,57 +211,55 @@ public class SpielFrame extends JFrame {
} }
} }
/** /**
* Sets the default background color for the buttons in the grid. * Sets the default background color for the buttons in the grid.
*/ */
private void setDefaultBackground() { private void setDefaultBackground() {
int counter = 8; int counter = 8;
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
JButton b = buttons.get(i); JButton b = buttons.get(i);
if ((i / 8 + i % 8) % 2 == 0) { if ((i / 8 + i % 8) % 2 == 0) {
// logger.info("Helles Feld erstellt." + i); // logger.info("Helles Feld erstellt." + i);
b.setBackground(new Color(90, 90, 90)); b.setBackground(new Color(90, 90, 90));
} else {
// logger.info("Dunkles Feld erstellt." + i);
b.setBackground(new Color(65, 65, 65));
}
} else { if (i % 8 == 0) {
// logger.info("Dunkles Feld erstellt." + i); b.setHorizontalAlignment(SwingConstants.CENTER);
b.setBackground(new Color(65, 65, 65)); b.setVerticalAlignment(SwingConstants.CENTER);
}
if(i % 8 == 0) { b.setHorizontalTextPosition(SwingConstants.LEFT); // Text rechts vom Icon
b.setHorizontalAlignment(SwingConstants.CENTER); b.setVerticalTextPosition(SwingConstants.BOTTOM);
b.setVerticalAlignment(SwingConstants.CENTER);
b.setHorizontalTextPosition(SwingConstants.LEFT); // Text rechts vom Icon b.setIconTextGap(5);
b.setVerticalTextPosition(SwingConstants.BOTTOM);
b.setIconTextGap(5); b.setText(String.valueOf(counter) + b.getText());
counter--;
}
}
b.setText(String.valueOf(counter)+b.getText()); char buchstabe = 'a';
counter--; 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);
char buchstabe = 'a'; button.setIconTextGap(5);
for(int j=0;j<8;j++) {
JButton button = buttons.get(mirrowedGrid(j));
button.setHorizontalAlignment(SwingConstants.CENTER); button.setText(String.valueOf(buchstabe));
button.setVerticalAlignment(SwingConstants.CENTER); buchstabe++;
}
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 * Sets the to default buttons
*/ */
public void setDefaultButtons() { public void setDefaultButtons() {
@ -322,11 +320,9 @@ public class SpielFrame extends JFrame {
break; break;
case finished: case finished:
clearButtons();
break; break;
case gameEnd: case gameEnd:
break; break;
default: default: