From 54e73f2b855984752f1daa60f7be616f46990292 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 12 Jul 2019 13:33:34 +0200 Subject: [PATCH] Made application terminate when GameModeDialog is closed --- src/dev/kske/chess/ui/GameModeDialog.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dev/kske/chess/ui/GameModeDialog.java b/src/dev/kske/chess/ui/GameModeDialog.java index aa65134..6c64172 100644 --- a/src/dev/kske/chess/ui/GameModeDialog.java +++ b/src/dev/kske/chess/ui/GameModeDialog.java @@ -1,6 +1,8 @@ package dev.kske.chess.ui; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.HashMap; import java.util.Map; @@ -35,6 +37,15 @@ public class GameModeDialog extends JDialog { setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + // Exit application when the close button is pressed + addWindowListener(new WindowAdapter() { + + @Override + public void windowClosing(WindowEvent evt) { + System.exit(0); + } + }); + final BoardComponent boardComponent = boardPane.getBoardComponent(); final OverlayComponent overlayComponent = boardPane.getOverlayComponent(); final Board board = boardComponent.getBoard();