FileDocCategorySizeDatePackage
TextBox2MIDlet.javaAPI DocExample1977Mon Oct 08 23:21:02 BST 2001ora.ch4

TextBox2MIDlet

public class TextBox2MIDlet extends TextBoxMIDlet implements javax.microedition.lcdui.CommandListener

Fields Summary
private static final javax.microedition.lcdui.Command
EXIT_COMMAND
private static final javax.microedition.lcdui.Command
OK_COMMAND
private static final javax.microedition.lcdui.Command
CLEAR_COMMAND
private static final javax.microedition.lcdui.Command
REVERSE_COMMAND
Constructors Summary
Methods Summary
public voidcommandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)

        if (c == EXIT_COMMAND) {
            destroyApp(true);
            notifyDestroyed();
        } else if (c == OK_COMMAND) {
            System.out.println("OK pressed");
        } else if (c == CLEAR_COMMAND) {
            textBox.setString(null);
        } else if (c == REVERSE_COMMAND) {
            String str = textBox.getString();
            if (str != null) {
                StringBuffer sb = new StringBuffer(str);
                textBox.setString(sb.reverse().toString());
            }            
        }
    
protected voidstartApp()


       
        boolean firstTime = !started;
        super.startApp();
        
        // If this is the first execution
        // of startApp, install commands
        if (firstTime) {
            textBox.addCommand(OK_COMMAND);            
            textBox.addCommand(EXIT_COMMAND);
            textBox.addCommand(CLEAR_COMMAND);            
            textBox.addCommand(REVERSE_COMMAND);            
            textBox.setCommandListener(this);
        }