diff --git a/src/main/java/com/charego/freecellfx/FreeCellApplication.java b/src/main/java/com/charego/freecellfx/FreeCellApplication.java index 70eb86c..a3d9299 100644 --- a/src/main/java/com/charego/freecellfx/FreeCellApplication.java +++ b/src/main/java/com/charego/freecellfx/FreeCellApplication.java @@ -4,6 +4,7 @@ import com.charego.freecellfx.model.Game; import com.charego.freecellfx.view.GameCanvas; import com.charego.freecellfx.view.GameMenuBar; import javafx.application.Application; +import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.layout.*; @@ -29,6 +30,7 @@ public class FreeCellApplication extends Application { menuBar.setNewGameAction(canvas.getNewGameAction()); menuBar.setUndoAction(canvas.getUndoAction()); menuBar.setRedoAction(canvas.getRedoAction()); + menuBar.setExitAction(e -> Platform.exit()); root.getChildren().addAll(menuBar, canvas); Scene scene = new Scene(root); diff --git a/src/main/java/com/charego/freecellfx/view/GameMenuBar.java b/src/main/java/com/charego/freecellfx/view/GameMenuBar.java index e45cb0c..b539a31 100644 --- a/src/main/java/com/charego/freecellfx/view/GameMenuBar.java +++ b/src/main/java/com/charego/freecellfx/view/GameMenuBar.java @@ -32,6 +32,7 @@ public class GameMenuBar extends MenuBar { newGame.setAccelerator(new KeyCodeCombination(KeyCode.F2)); undoMove.setAccelerator(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN)); redoMove.setAccelerator(new KeyCodeCombination(KeyCode.Y, KeyCombination.CONTROL_DOWN)); + exitGame.setAccelerator(new KeyCodeCombination(KeyCode.ESCAPE)); } public void setNewGameAction(EventHandler handler) { @@ -46,4 +47,8 @@ public class GameMenuBar extends MenuBar { redoMove.setOnAction(handler); } + public void setExitAction(EventHandler handler) { + exitGame.setOnAction(handler); + } + }