Goodbye World : Basics « J2ME « Java






Goodbye World

Goodbye World
/*
MIDlet-Name: Hello World
MIDlet-Version: 1.0
MIDlet-Vendor: Jim
MIDlet-Description: My First MIDlet suite
MIDlet-1: HelloWorld, /greeting/myLogo.png, greeting.HelloWorld
MIDlet-2: GoodbyeWorld, /greeting/myLogo.png, greeting.GoodbyeWorld
MIDlet-Jar-URL: HelloWorld.jar
MIDlet-Jar-Size: 4048

*/


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.midlet.MIDlet;

public class GoodbyeWorld extends MIDlet implements CommandListener {
  private Display display;

  private TextBox textBox = new TextBox("Goodbye World", "My second MIDlet", 40, 0);

  private Command quitCommand = new Command("Quit", Command.SCREEN, 1);

  public void startApp() {
    display = Display.getDisplay(this);
    textBox.addCommand(quitCommand);
    textBox.setCommandListener(this);
    display.setCurrent(textBox);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command choice, Displayable displayable) {
    if (choice == quitCommand) {
      destroyApp(false);
      notifyDestroyed();
    }
  }
}


           
       








Related examples in the same category

1.Example MIDletExample MIDlet
2.Hello MidletHello Midlet
3.Simple Midlet DemoSimple Midlet Demo
4.Basic MIDlet Shell
5.Welcome MIDletWelcome MIDlet
6.Welcome BackWelcome Back
7.Example jad file
8.MIDlet lifecycleMIDlet lifecycle
9.MIDlet State TransitionsMIDlet State Transitions