example.manyballs
Class ManyCanvas

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by example.manyballs.ManyCanvas

public class ManyCanvas
extends javax.microedition.lcdui.Canvas


Field Summary
(package private)  SmallBall[] balls
           
(package private)  javax.microedition.lcdui.Display display
           
(package private)  int height
           
(package private)  boolean menuShowing
           
(package private)  java.lang.String msg
          Draws the drawing frame (which also contains the ball) and the controls.
(package private) static int NUM_HISTORY
           
(package private)  int numBalls
           
(package private)  boolean paused
           
(package private)  long[] times
           
(package private)  int times_idx
           
(package private)  int width
           
 
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
ManyCanvas(javax.microedition.lcdui.Display d, int maxBalls)
           
 
Method Summary
(package private)  void destroy()
           
protected  void hideNotify()
           
(package private)  boolean isPaused()
           
 void keyPressed(int keyCode)
          Handle a pen down event.
 void notifyBallThreadStarted()
           
 void notifyBallThreadStopped()
           
protected  void paint(javax.microedition.lcdui.Graphics g)
           
(package private)  void pause()
          Pause the balls by signaling each of them to stop.
protected  void showNotify()
           
(package private)  void start()
           
 void waitForSpecifiedNumberOfThreads(int threadNumber)
           
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_HISTORY

static int NUM_HISTORY

display

javax.microedition.lcdui.Display display

balls

SmallBall[] balls

numBalls

int numBalls

width

int width

height

int height

paused

boolean paused

menuShowing

boolean menuShowing

times

long[] times

times_idx

int times_idx

msg

java.lang.String msg
Draws the drawing frame (which also contains the ball) and the controls.

Constructor Detail

ManyCanvas

public ManyCanvas(javax.microedition.lcdui.Display d,
                  int maxBalls)
Method Detail

paint

protected void paint(javax.microedition.lcdui.Graphics g)
Specified by:
paint in class javax.microedition.lcdui.Canvas

keyPressed

public void keyPressed(int keyCode)
Handle a pen down event.

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

destroy

void destroy()

isPaused

boolean isPaused()

hideNotify

protected void hideNotify()
Overrides:
hideNotify in class javax.microedition.lcdui.Canvas

showNotify

protected void showNotify()
Overrides:
showNotify in class javax.microedition.lcdui.Canvas

pause

void pause()
Pause the balls by signaling each of them to stop. The ball object still exists and holds the current position of the ball. It may be restarted later. The thread will terminate. TBD: is a join needed?


start

void start()

notifyBallThreadStarted

public void notifyBallThreadStarted()

notifyBallThreadStopped

public void notifyBallThreadStopped()

waitForSpecifiedNumberOfThreads

public void waitForSpecifiedNumberOfThreads(int threadNumber)