TransformDemo.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- // Any use of this code and/or information below is subject to the
- // license terms: http://wireless.java.sun.com/berkeley_license.html
- import java.io.IOException;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- public class TransformDemo extends MIDlet implements CommandListener {
- private MyCanvas myCanvas; //声明MicroTankCanvas
- public void startApp() //开始程序
- {
- if (myCanvas == null)
- {
- try {
- myCanvas = new MyCanvas();//构造实例,注意,之前要判断
- myCanvas.start(); //调用start函数
- Command exitCommand = new Command("Exit", Command.EXIT, 0);//添加exit按键
- myCanvas.addCommand(exitCommand);
- myCanvas.setCommandListener(this);
- }
- catch (IOException ioe)
- {
- System.out.println(ioe);
- }
- }
- Display.getDisplay(this).setCurrent(myCanvas);//设置display
- }
- public void pauseApp() {}
- public void destroyApp(boolean unconditional)
- {
- if (myCanvas != null)
- myCanvas.stop();//调用stop函数
- }
- public void commandAction(Command c, Displayable s) {
- if (c.getCommandType() == Command.EXIT) {
- destroyApp(true);
- notifyDestroyed();//退出
- }
- }
- }