diff options
author | Pacien TRAN-GIRARD | 2014-02-24 20:51:10 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-02-24 20:51:10 +0100 |
commit | 818d0e52340f9c32ab3c85d97c1a433de3eb3402 (patch) | |
tree | 79a49aa4933b89a7ebfb9357f1bc38e308ef64e0 /src | |
parent | e38a8ebb5fbb85082297a25b1fcf29283b599114 (diff) | |
download | esieequest-818d0e52340f9c32ab3c85d97c1a433de3eb3402.tar.gz |
Make an applet
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/Game.java | 4 | ||||
-rw-r--r-- | src/esieequest/GameEngine.java | 1 | ||||
-rw-r--r-- | src/esieequest/UserInterface.java | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 925f067..a35cfb4 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java | |||
@@ -1,5 +1,7 @@ | |||
1 | package esieequest; | 1 | package esieequest; |
2 | 2 | ||
3 | import javax.swing.JApplet; | ||
4 | |||
3 | /** | 5 | /** |
4 | * The game engine. | 6 | * The game engine. |
5 | * | 7 | * |
@@ -12,7 +14,7 @@ package esieequest; | |||
12 | * | 14 | * |
13 | * @version February 2014 | 15 | * @version February 2014 |
14 | */ | 16 | */ |
15 | public class Game { | 17 | public class Game extends JApplet { |
16 | private UserInterface aGui; | 18 | private UserInterface aGui; |
17 | private GameEngine aEngine; | 19 | private GameEngine aEngine; |
18 | 20 | ||
diff --git a/src/esieequest/GameEngine.java b/src/esieequest/GameEngine.java index 3a89413..c20c70c 100644 --- a/src/esieequest/GameEngine.java +++ b/src/esieequest/GameEngine.java | |||
@@ -229,6 +229,7 @@ public class GameEngine { | |||
229 | private void endGame() { | 229 | private void endGame() { |
230 | this.aGui.println("Thank you for playing. Good bye."); | 230 | this.aGui.println("Thank you for playing. Good bye."); |
231 | this.aGui.enable(false); | 231 | this.aGui.enable(false); |
232 | this.aGui.killFrame(); | ||
232 | } | 233 | } |
233 | 234 | ||
234 | /** | 235 | /** |
diff --git a/src/esieequest/UserInterface.java b/src/esieequest/UserInterface.java index 4f3e19e..949348e 100644 --- a/src/esieequest/UserInterface.java +++ b/src/esieequest/UserInterface.java | |||
@@ -112,6 +112,12 @@ public class UserInterface implements ActionListener { | |||
112 | 112 | ||
113 | this.aEntryField.addActionListener(this); | 113 | this.aEntryField.addActionListener(this); |
114 | 114 | ||
115 | this.aMyFrame.addWindowListener(new WindowAdapter() { | ||
116 | public void windowClosing(WindowEvent e) { | ||
117 | killFrame(); | ||
118 | } | ||
119 | }); | ||
120 | |||
115 | this.aMyFrame.pack(); | 121 | this.aMyFrame.pack(); |
116 | this.aMyFrame.setVisible(true); | 122 | this.aMyFrame.setVisible(true); |
117 | this.aEntryField.requestFocus(); | 123 | this.aEntryField.requestFocus(); |
@@ -137,4 +143,9 @@ public class UserInterface implements ActionListener { | |||
137 | 143 | ||
138 | this.aEngine.interpretCommand(vInput); | 144 | this.aEngine.interpretCommand(vInput); |
139 | } | 145 | } |
146 | |||
147 | public void killFrame() { | ||
148 | this.aMyFrame.setVisible(false); | ||
149 | this.aMyFrame.dispose(); | ||
150 | } | ||
140 | } | 151 | } |