Commander : Event Command « J2ME « Java






Commander

Commander
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class Commander extends MIDlet {
  public void startApp() {
    Displayable d = new TextBox("TextBox", "Commander", 20, TextField.ANY);

    Command c = new Command("Exit", Command.EXIT, 0);
    d.addCommand(c);
    d.setCommandListener(new CommandListener() {
      public void commandAction(Command c, Displayable s) {
        notifyDestroyed();
      }
    });

    Display.getDisplay(this).setCurrent(d);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }
}


           
       








Related examples in the same category

1.Simple Command DemoSimple Command Demo
2.Various EventVarious Event
3.Commands, Items, and Event ProcessingCommands, Items, and Event Processing
4.Api concepts Refer to the startApp pauseApp, and destroyAppApi concepts Refer to the startApp pauseApp, and destroyApp
5.An example MIDlet with simple Hello text and an Exit commandAn example MIDlet with simple Hello text and an Exit command
6.Online Help
7.A first MIDlet with simple text and a few commands.A first MIDlet with simple text and a few commands.
8.Many CommandsMany Commands
9.Mapping CommandsMapping Commands
10.Capture Item EventsCapture Item Events
11.Accessing CommandsAccessing Commands
12.A quick sample of graphics, commands, and event handling.A quick sample of graphics,  commands, and event handling.