midletmain.java
来自「《精通JAVA手机游戏与应用程序设计》随书光盘」· Java 代码 · 共 60 行
JAVA
60 行
package manually;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class MIDletMain extends MIDlet {
static MIDletMain instance;
MyCanvas displayable = new MyCanvas();
Timer iTimer = new Timer();
/**
* Construct the midlet.
*/
public MIDletMain() {
MIDletMain.instance = this;
}
/**
* Main method.
*/
public void startApp() {
Display.getDisplay(this).setCurrent(displayable);
iTimer.schedule( new MyTimerTask(), 0, 40 );
}
/**
* Handle pausing the MIDlet.
*/
public void pauseApp() {
}
/**
* Handle destroying the MIDlet.
*/
public void destroyApp(boolean unconditional) {
}
/**
* Quit the MIDlet.
*/
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
/**
* Timer task for providing animation.
*/
class MyTimerTask extends TimerTask {
public void run() {
if( displayable != null ) {
displayable.repaint();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?