commandTest.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- package commandTest;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.*;
- public class commandTest extends MIDlet implements CommandListener
- {
- private Display display;
- private commandTestCanvas myCanvas;
- private Command exitCmd = new Command(" 退出", Command.SCREEN, 1);
- private Command okCmd = new Command("确定", Command.SCREEN, 1);
- private Command backCmd = new Command("后退", Command.SCREEN, 1);
- public commandTest()
- {
- myCanvas = new commandTestCanvas();
- display = Display.getDisplay(this);
- myCanvas.addCommand(okCmd);
- myCanvas.addCommand(backCmd);
- myCanvas.addCommand(exitCmd);
- myCanvas.setCommandListener(this);
- }
- public void startApp()
- {
- display.setCurrent(myCanvas);
- }
- public void pauseApp()
- {
- }
- public void destroyApp(boolean unconditional)
- {
- }
- public void commandAction(Command cmd, Displayable disp) {
- System.out.println("command");
- if(cmd == exitCmd){
- destroyApp(false);
- notifyDestroyed();
- }
- }
- }