import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class Mobile extends MIDlet implements CommandListener
...{
private Display display;
private Form mainForm;
private StringItem stringItem;
private Command exitCommand = new Command("Exit", Command.EXIT, 1);
public static final String WEB_SITE = "WEB_SITE";
protected void startApp() throws MIDletStateChangeException
...{
initMIDlet();
display.setCurrent(mainForm);
}
private void initMIDlet()
...{
display = Display.getDisplay(this);
mainForm = new Form("Hello World");
stringItem = new StringItem(null, null);
String text = getAppProperty(WEB_SITE);
stringItem.setText(text);
mainForm.append(stringItem);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
}
protected void pauseApp()
...{
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException
...{
System.out.println("exit the application");
}
public void commandAction(Command cmd, Displayable display)
...{
if (cmd == exitCommand)
...{
try
...{
destroyApp(false);
notifyDestroyed();
} catch (MIDletStateChangeException e)
...{
e.printStackTrace();
}
}
}
}

被折叠的 条评论
为什么被折叠?



