FileDocCategorySizeDatePackage
ManyBalls.javaAPI DocJ2ME MIDP 2.02505Thu Nov 07 12:02:18 GMT 2002example.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 Command
aboutCommand
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.addCommand(aboutCommand);
	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) {
	    }
	} else if (c == aboutCommand) {
	    About.showAbout(display);
	}
    
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();