m3g03.midp2
Class GameCanvasKeyStates

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by javax.microedition.lcdui.game.GameCanvas
              extended by m3g03.midp2.GameCanvasKeyStates
All Implemented Interfaces:
java.lang.Runnable

public class GameCanvasKeyStates
extends javax.microedition.lcdui.game.GameCanvas
implements java.lang.Runnable

Displays key states read from GameCanvas.getKeyStates(). This method only returns game actions, not general purpose keys.

Author:
Claus Hoefele

Field Summary
private  javax.microedition.lcdui.Graphics graphics
          Graphics singleton used for rendering.
private  boolean isRunning
          Flag for stopping the Thread.
private static java.util.Hashtable KEY_STATES
          Maps key states to a name that can be displayed.
 
Fields inherited from class javax.microedition.lcdui.game.GameCanvas
DOWN_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED, GAME_D_PRESSED, LEFT_PRESSED, RIGHT_PRESSED, UP_PRESSED
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
GameCanvasKeyStates()
          Constructor.
 
Method Summary
 void hideNotify()
          Stops the display loop.
private  void render(javax.microedition.lcdui.Graphics graphics)
          Renders the key states.
 void run()
          Drives the animation.
 void showNotify()
          Called when this sample is displayed.
 
Methods inherited from class javax.microedition.lcdui.game.GameCanvas
flushGraphics, flushGraphics, getGraphics, getKeyStates, paint
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isRunning

private boolean isRunning
Flag for stopping the Thread.


graphics

private javax.microedition.lcdui.Graphics graphics
Graphics singleton used for rendering.


KEY_STATES

private static final java.util.Hashtable KEY_STATES
Maps key states to a name that can be displayed.

Constructor Detail

GameCanvasKeyStates

public GameCanvasKeyStates()
Constructor.

Method Detail

showNotify

public void showNotify()
Called when this sample is displayed. Starts the display loop.

Overrides:
showNotify in class javax.microedition.lcdui.Canvas

hideNotify

public void hideNotify()
Stops the display loop.

Overrides:
hideNotify in class javax.microedition.lcdui.Canvas

run

public void run()
Drives the animation.

Specified by:
run in interface java.lang.Runnable

render

private void render(javax.microedition.lcdui.Graphics graphics)
Renders the key states.

Parameters:
graphics - graphics context for rendering.