FileDocCategorySizeDatePackage
ManyBalls.javaAPI DocphoneME MR2 API (J2ME)3177Wed May 02 18:00:24 BST 2007com.sun.midp.demos.manyballs

ManyBalls

public class ManyBalls extends MIDlet implements CommandListener

Fields Summary
Display
display
ManyCanvas
canvas
private Command
exitCommand
private Command
toggleCommand
private Command
helpCommand
private Form
helpScreen
private String
helpText
Constructors Summary
public ManyBalls()



    // the GUI buttons
    //	Button exitButton, clearButton, moreButton, lessButton;

    /*
     * Create the canvas
     */
      
	display = Display.getDisplay(this);

	canvas = new ManyCanvas(display, 40);
	canvas.addCommand(exitCommand);
	canvas.addCommand(toggleCommand);
	canvas.addCommand(helpCommand);
	canvas.setCommandListener(this);
    
Methods Summary
public voidcommandAction(Command c, Displayable s)

	if (c == toggleCommand) {
	    if (canvas.isPaused())
		canvas.start();
	    else
		canvas.pause();
	} else if (c == helpCommand) {
	    canvas.pause();
	    showHelp();
	} else if (c == exitCommand) {
	    try {
		destroyApp(false);
		notifyDestroyed();
	    } catch (MIDletStateChangeException ex) {
	    }
	}
    
public voiddestroyApp(boolean unconditional)

	canvas.destroy();
    
public voidpauseApp()

	canvas.pause();
    
voidshowHelp()

	if (helpScreen == null) {
	    helpScreen = new Form("Many Balls Help");
	    helpScreen.append("^ = faster\n");
	    helpScreen.append("v = slower\n");
	    helpScreen.append("< = fewer\n");
	    helpScreen.append("> = more\n");
	}
	helpScreen.addCommand(toggleCommand);
	helpScreen.setCommandListener(this);
	display.setCurrent(helpScreen);
    
public voidstartApp()

	canvas.start();