📄 timerdemo_2.java
字号:
package TimerDemo;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
public class TimerDemo_2 extends MIDlet implements CommandListener{
private MyTimerTask myTimerTask;
private Timer myTimer;
private StarCanvas star;
private Command exitCommand;
public TimerDemo_2() {
exitCommand = new Command("Exit", Command.EXIT, 1);
star = new StarCanvas();
star.addCommand(exitCommand);
Display.getDisplay(this).setCurrent(star);
myTimer = new Timer();
myTimerTask = new MyTimerTask();
myTimer.schedule(myTimerTask,50,100);
}
protected void startApp() {
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
class MyTimerTask extends TimerTask{
public void run(){
if(star != null)
star.repaint();
//this.cancel();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -