better termination
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user