📄 simpletimermidlet.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class SimpleTimerMIDlet extends MIDlet implements CommandListener {
private Command exitCommand;
private Command scheduleCommand;
private TextBox aTextBox;
public static String aMessage="";
Display display;
private Timer aTimer;
private SimpleTimerTask aTimerTask;
public SimpleTimerMIDlet() {
Display display = Display.getDisplay(this);
exitCommand = new Command("离开", Command.EXIT, 1);
scheduleCommand = new Command("调度",Command.SCREEN,1);
}
public void startApp(){
aTextBox = new TextBox("定时", "调度内容", 20, 0);
aTextBox.addCommand(exitCommand);
aTextBox.addCommand(scheduleCommand);
aTextBox.setCommandListener(this);
display.setCurrent(aTextBox);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if(c == scheduleCommand){
aTimer = new Timer();
aTimerTask = new SimpleTimerTask();
aTimer.schedule(aTimerTask,500);
aTextBox.setString(aMessage);
}
else if (c == exitCommand){
destroyApp(false);
notifyDestroyed();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -