From 897353efeb1fc6b06e14d19a382ef6b018e66996 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 6 Sep 2019 13:24:58 +0200 Subject: [PATCH] Fixed frozen game after adding a new one --- src/dev/kske/chess/ui/MenuBar.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dev/kske/chess/ui/MenuBar.java b/src/dev/kske/chess/ui/MenuBar.java index d3359d4..84f1b94 100644 --- a/src/dev/kske/chess/ui/MenuBar.java +++ b/src/dev/kske/chess/ui/MenuBar.java @@ -38,7 +38,9 @@ public class MenuBar extends JMenuBar { dialog.setVisible(true); if (dialog.isStartGame()) { GamePane gamePane = mainWindow.addGamePane(); - gamePane.setGame(new Game(gamePane.getBoardPane(), dialog.getWhiteName(), dialog.getBlackName())); + Game game = new Game(gamePane.getBoardPane(), dialog.getWhiteName(), dialog.getBlackName()); + gamePane.setGame(game); + game.start(); } }); gameMenu.add(newGameMenuItem); @@ -56,7 +58,8 @@ public class MenuBar extends JMenuBar { JMenuItem addEngineMenuItem = new JMenuItem("Add engine"); addEngineMenuItem.addActionListener((evt) -> { String enginePath = JOptionPane.showInputDialog(getParent(), - "Enter the path to a UCI-compatible chess engine:", "Engine selection", + "Enter the path to a UCI-compatible chess engine:", + "Engine selection", JOptionPane.QUESTION_MESSAGE); if (enginePath != null) EngineUtil.addEngine(enginePath); });