diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ch/epfl/xblast/simulation/GraphicalSimulation.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/ch/epfl/xblast/simulation/GraphicalSimulation.java b/test/ch/epfl/xblast/simulation/GraphicalSimulation.java index 8009d9f..9329cc7 100644 --- a/test/ch/epfl/xblast/simulation/GraphicalSimulation.java +++ b/test/ch/epfl/xblast/simulation/GraphicalSimulation.java | |||
@@ -11,6 +11,7 @@ import ch.epfl.xblast.server.Level; | |||
11 | import ch.epfl.xblast.server.painter.BoardPainter; | 11 | import ch.epfl.xblast.server.painter.BoardPainter; |
12 | 12 | ||
13 | import javax.swing.*; | 13 | import javax.swing.*; |
14 | import java.awt.*; | ||
14 | import java.awt.event.KeyEvent; | 15 | import java.awt.event.KeyEvent; |
15 | import java.util.Collections; | 16 | import java.util.Collections; |
16 | import java.util.HashMap; | 17 | import java.util.HashMap; |
@@ -48,27 +49,28 @@ public class GraphicalSimulation extends Simulation { | |||
48 | return GameStateDeserializer.deserialize(serializedGameState); | 49 | return GameStateDeserializer.deserialize(serializedGameState); |
49 | } | 50 | } |
50 | 51 | ||
51 | private static JFrame buildFrame(XBlastComponent gui) { | 52 | private static JFrame buildFrame(Container content) { |
52 | JFrame frame = new JFrame(); | 53 | JFrame frame = new JFrame(); |
53 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | 54 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
54 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | 55 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
55 | frame.setVisible(true); | 56 | frame.setVisible(true); |
56 | 57 | ||
57 | frame.setContentPane(gui); | 58 | frame.setContentPane(content); |
58 | frame.pack(); | 59 | frame.pack(); |
59 | return frame; | 60 | return frame; |
60 | } | 61 | } |
61 | 62 | ||
62 | private void attachKeyboardHandler(JFrame frame) { | 63 | private void attachKeyboardHandler(Component comp) { |
63 | frame.addKeyListener(new KeyboardEventHandler(buildPlayerActionMap(), PLAYER_ACTION_CONSUMER)); | 64 | comp.addKeyListener(new KeyboardEventHandler(buildPlayerActionMap(), PLAYER_ACTION_CONSUMER)); |
64 | frame.requestFocusInWindow(); | 65 | comp.requestFocusInWindow(); |
65 | } | 66 | } |
66 | 67 | ||
67 | private final XBlastComponent gui; | 68 | private final XBlastComponent gui; |
68 | 69 | ||
69 | private GraphicalSimulation() { | 70 | private GraphicalSimulation() { |
70 | this.gui = new XBlastComponent(); | 71 | this.gui = new XBlastComponent(); |
71 | attachKeyboardHandler(buildFrame(this.gui)); | 72 | buildFrame(this.gui); |
73 | attachKeyboardHandler(this.gui); | ||
72 | } | 74 | } |
73 | 75 | ||
74 | @Override | 76 | @Override |