ui_ex12.java

来自「J2ME 无线通信技术应用开发源代码」· Java 代码 · 共 47 行

JAVA
47
字号
// 程序名UI_Ex12.java
// 测试List类
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class UI_Ex12 extends MIDlet implements CommandListener{
  private Display display; // 引用MIDlet的Display 对象
  private List list; //声明List类
  private Command cmdExit;

  // MIDlet构造程序
  public UI_Ex12() {
    display = Display.getDisplay(this);
    cmdExit = new Command("Exit",Command.SCREEN,1);
    /*
    list = new List( "Choose direction:", List.EXCLUSIVE );//MULTIPLE IMPLICIT
    list.append( "Ease", null );
    list.append( "West", null );
    list.append( "South", null );
    list.append( "North", null );
    */
    String[] directionStr = {"East","West","South","North"};
    list = new List("Choose direction:",List.MULTIPLE,directionStr,null);
    list.addCommand(cmdExit);
    list.setCommandListener(this);
  }

  // 被应用程序管理器调用来启动MIDlet。
  public void startApp() {
    display.setCurrent(list);
  }

  // 一个必要的方法
  public void pauseApp() {
  }

  //一个必要的方法
  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command c, Displayable d) {
    if (c == cmdExit) {
      destroyApp(false);
      notifyDestroyed();
    }
 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?