一个j2me小程序.有些地方不懂

来源:百度知道 编辑:UC知道 时间:2024/06/08 04:00:12
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class AlertWithTextBoxMIDlet extends MIDlet implements CommandListener
{
private Display display;
public AlertWithTextBoxMIDlet()
{
display = Display.getDisplay(this);
}
public void startApp()
{
TextBox tb = new TextBox("text box","欢迎加入数字传媒系游戏二班 MIDP GUI 编程世界!", 40, TextField.ANY);
Alert timedAlert = new Alert("Login","游戏二班J2ME课堂", null, AlertType.CONFIRMATION);
timedAlert.setTimeout(5000);
tb.addCommand(new Command("退出",Command.OK,1));
tb.setCommandListener(this);
display.setCurrent(timedAlert, tb);
}
public void commandAction(Command c, Displayable s)
{
if(c.getLabel().equals("退出"))
{
destroyApp(true); notifyDestroyed

notifyDestroyed()是退出程序用的,用于一个MIDlet来通知AMS(应用管理软件)它已经进入destroyed状态,implements CommandListener是使用CommandListener接口,以使用按键功能,不然的话,public void commandAction(Command c, Displayable s)
此方法就无法使用了
先后顺序,你可以在每个方法前面打印一些信息出来,然后就能清楚它的顺序了
这些东西能在百度上查到的
下次给分时多给点
另外,你是哪个学校的?