From 490db60d6bae57893f8e39102f7e5aac1de7176b Mon Sep 17 00:00:00 2001 From: delvh Date: Tue, 23 Jul 2019 11:02:34 +0200 Subject: [PATCH] Added checkmate and stalemate notification through dialog, changed icon --- src/dev/kske/chess/game/Game.java | 6 +++++- src/dev/kske/chess/ui/MainWindow.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dev/kske/chess/game/Game.java b/src/dev/kske/chess/game/Game.java index 8bd4456..5cf150c 100644 --- a/src/dev/kske/chess/game/Game.java +++ b/src/dev/kske/chess/game/Game.java @@ -3,6 +3,8 @@ package dev.kske.chess.game; import java.util.HashMap; import java.util.Map; +import javax.swing.JOptionPane; + import dev.kske.chess.board.Board; import dev.kske.chess.board.GameState; import dev.kske.chess.board.Move; @@ -78,7 +80,9 @@ public class Game { switch (eventType) { case CHECKMATE: case STALEMATE: - System.out.printf("%s in %s!%n", player.color.opposite(), eventType); + String result = String.format("%s in %s!%n", player.color.opposite(), eventType); + System.out.print(result); + JOptionPane.showMessageDialog(boardComponent, result); break; case CHECK: System.out.printf("%s in check!%n", player.color.opposite()); diff --git a/src/dev/kske/chess/ui/MainWindow.java b/src/dev/kske/chess/ui/MainWindow.java index b103a47..29f32af 100644 --- a/src/dev/kske/chess/ui/MainWindow.java +++ b/src/dev/kske/chess/ui/MainWindow.java @@ -59,7 +59,7 @@ public class MainWindow { mframe.setBounds(100, 100, 494, 565); mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - mframe.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pieces/king_white.png"))); + mframe.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pieces/queen_white.png"))); boardPane = new BoardPane(); mframe.getContentPane().add(boardPane, BorderLayout.CENTER);