better termination

This commit is contained in:
2025-04-12 13:04:48 +02:00
parent de733fcea2
commit 39c289cc47
4 changed files with 18 additions and 6 deletions

View File

@@ -205,7 +205,7 @@ public class Window extends JFrame implements GameListener {
public void winnerIs(chess.model.Color color) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(this, "Victory of " + color);
this.dispose();
onGameEnd();
});
}
@@ -229,7 +229,7 @@ public class Window extends JFrame implements GameListener {
public void patSituation() {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(this, "Pat. It's a draw!");
this.dispose();
onGameEnd();
});
}
@@ -240,6 +240,11 @@ public class Window extends JFrame implements GameListener {
});
}
private void onGameEnd() {
this.dispose();
this.commandExecutor.close();
}
@Override
public void gameStarted() {
buildBoard();