/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.*;
/**
* @author Administrator
*/
public class j2ME_01 extends MIDlet implements CommandListener{
Display display1;
Form showForm ;
Command exitcommand;
StringItem s ;
public j2ME_01() {
display1 = Display.getDisplay(this);
showForm = new Form("测试退出按钮");
//添加文字
s = new StringItem("Hi","这是我地一个J2ME程序");
showForm.append(s);
//添加按钮
exitcommand = new Command("exit",Command.STOP,2);
showForm.addCommand(exitcommand);
showForm.setCommandListener(this);//添加按钮单击事件
}
public void startApp() {
display1.setCurrent(showForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void commandAction(Command c, Displayable d) {
destroyApp( true );
}
}