import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class Hello extends javax.microedition.midlet.MIDlet implements CommandListener{
protected Form form;
protected Command quit;
public Hello(){
form=new Form("我的MIDlet");
form.append("欢迎,MIDLET WORLD!");
form.setCommandListener(this);
quit=new Command("离开",Command.SCREEN,1);
form.addCommand(quit);
}
protected void startApp() throws MIDletStateChangeException
{ Display.getDisplay(this).setCurrent(form);
}
protected void pauseApp(){
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
{
}
public void commandAction(Command command,Displayable displayable)
{
try{
if(command==quit){
destroyApp(true);
notifyDestroyed();
}
}
catch(MIDletStateChangeException me){}
}
}
评论