FileDocCategorySizeDatePackage
BBall.javaAPI DocJ2ME MIDP 2.03206Thu Nov 07 12:02:20 GMT 2002example.audiodemo

BBall

public class BBall extends MIDlet implements CommandListener, Runnable

Fields Summary
private static final String[]
bgs
static String
wavbgUrl
private Command
exitCommand
private Command
playCommand
private Display
display
private int
idx
private static List
theList
private static BBall
instance
BallCanvas
game
Constructors Summary
public BBall()

        instance = this;
        display  = Display.getDisplay(this);
        theList  = new List("Backgrounds", Choice.IMPLICIT);
        for (int i = 0; i < bgs.length; i++) {
            theList.append(bgs[i], null);
        }
	wavbgUrl = getAppProperty("BBallURL");
        theList.addCommand(playCommand);
        theList.addCommand(exitCommand);
        theList.setCommandListener(this);
    
Methods Summary
public voidcommandAction(Command c, Displayable s)


        if (c == exitCommand) {
            destroyApp(false);
            notifyDestroyed();
       } else if ((s == theList && c == List.SELECT_COMMAND) || c == playCommand) {
            idx = theList.getSelectedIndex();
	    new Thread(this).start();
        }
    
public voiddestroyApp(boolean unconditional)
Destroy must cleanup everything not handled by the garbage collector.

	if (game != null)
	    game.destroy();
    
public static example.audiodemo.BBallgetInstance()


        
        return instance;
    
public static ListgetList()

        return theList;
    
public voidpauseApp()
Pause is a no-op since there are no background activities or record stores that need to be closed.

public voidrun()

	game = new BallCanvas(display, 5, idx);
	if (game.needAlert()) {
	    Alert alert = new Alert("Warning", "Can not create player", null, null);
	    alert.setTimeout(1000);
	    display.setCurrent(alert, game);
	} else {
	    display.setCurrent(game);
	}

	game.start();
    
public voidstartApp()

        display.setCurrent(theList);