diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 87fcbfb..494c682 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -10,6 +10,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.awt.event.WindowEvent; import java.util.LinkedList; public class WindowOfFreeMove extends JFrame { @@ -28,7 +29,9 @@ public class WindowOfFreeMove extends JFrame { public static final int KEY_RIGHT = 39; public static final int KEY_DOWN = 40; public static final int KEY_EVENT = 69; + public static final int KEY_FULLSCREEN = 115; + public static final int KEY_ESCAPE = 27; private Canvas canvas; private DialogBar dialogBar; @@ -47,6 +50,10 @@ public class WindowOfFreeMove extends JFrame { canvas.repaint(); } + private WindowOfFreeMove windowOfFreeMove(){ + return this; + } + public static void setCanPersonMove(boolean canPersonMove) { WindowOfFreeMove.canPersonMove = canPersonMove; } @@ -110,6 +117,10 @@ public class WindowOfFreeMove extends JFrame { addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KEY_ESCAPE){ + dispatchEvent(new WindowEvent(windowOfFreeMove(), WindowEvent.WINDOW_CLOSING)); + } + if (e.getKeyCode() == KEY_FULLSCREEN){ if (getExtendedState() == MAXIMIZED_BOTH) setExtendedState(NORMAL);