|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.KeyAdapter
javalib.funworld.MyKeyAdapter
class MyKeyAdapter
The implementation of callbacks for the key events.
Report all regular key presses, the four arrow keys, and some other special keys (backspace, delete, escape, page up, page down, home, end, tab, fkeys)
Ignore other key pressed events, key released events, etc.
Field Summary | |
---|---|
protected World |
currentWorld
the current
that handles the key events |
Constructor Summary | |
---|---|
protected |
MyKeyAdapter(World currentWorld)
the KeyAdapter that handles the key events |
Method Summary | |
---|---|
protected void |
displayInfo(KeyEvent e,
String s)
The key event major processor. |
protected void |
keyEventCallback(String keyString)
The callback for the key events |
void |
keyPressed(KeyEvent e)
Handle the key pressed event from the canvas. |
void |
keyTyped(KeyEvent e)
Handle the key typed event from the canvas. |
Methods inherited from class java.awt.event.KeyAdapter |
---|
keyReleased |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected World currentWorld
World
that handles the key events
Constructor Detail |
---|
protected MyKeyAdapter(World currentWorld)
KeyAdapter
that handles the key events
Method Detail |
---|
protected void displayInfo(KeyEvent e, String s)
The key event major processor. The code is adopted from the code provided by the Java documentation for key event processing.
We have to jump through some hoops to avoid trying to print non-printing characters such as Shift. (Not only do they not print, but if you put them in a String, the characters afterward won't show up in the text area.)
protected void keyEventCallback(String keyString)
public void keyPressed(KeyEvent e)
Handle the key pressed event from the canvas.
This is where we get the arrow keys.
keyPressed
in interface KeyListener
keyPressed
in class KeyAdapter
e
- the KeyEvent
that caused the callbackpublic void keyTyped(KeyEvent e)
Handle the key typed event from the canvas.
This is where we get the letter keys.
keyTyped
in interface KeyListener
keyTyped
in class KeyAdapter
e
- the KeyEvent
that caused the callback
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |