dualroids
Class InputHandler
java.lang.Object
|
+--java.awt.event.WindowAdapter
|
+--dualroids.InputHandler
- All Implemented Interfaces:
- EventListener, KeyListener, WindowListener
- public final class InputHandler
- extends WindowAdapter
- implements KeyListener
Class for handling keyboard input and windowClosing
window event.
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
ship
SpaceShip ship
- The ship that is controlled by this
InputHandler
.
connector
ClientModelConnector connector
- The associated
ClientModelConnector
.
InputHandler
public InputHandler(ClientModelConnector connector)
- Contructs a new
InputHandler
.
- Parameters:
connector
- the ClientModelConnector
to
be associated with this InputHandler
registerShip
public void registerShip(SpaceShip ship)
- Registers a
SpaceShip
for contrilling through
this InputHandler
.
- Parameters:
ship
- the ship to be controlled
keyPressed
public void keyPressed(KeyEvent ke)
- Handles key pressed events.
- Specified by:
keyPressed
in interface KeyListener
- Parameters:
ke
- the event
keyReleased
public void keyReleased(KeyEvent ke)
- Handles key released events.
- Specified by:
keyReleased
in interface KeyListener
- Parameters:
ke
- the event
keyTyped
public void keyTyped(KeyEvent ke)
- Dummy handler for key typed events.
- Specified by:
keyTyped
in interface KeyListener
- Parameters:
ke
- the event
windowClosing
public void windowClosing(WindowEvent event)
- Clean up the window and initiate a network close procedure when the
window close event is made. The network close will eventually cause
an
exit()
to be called when everything is safely closed.
- Overrides:
windowClosing
in class WindowAdapter
- Parameters:
event
- the window event
Dualroids was written by Oskar Ojala, Yrjö Kari-Koskinen and Henri Sivonen