?? lightmidlet.java
字號(hào):
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class LightMIDlet extends MIDlet {
static LightMIDlet instance;
LightForm displayable = new LightForm(this);
public LightMIDlet() {
instance = this;
}
public void startApp() {
Display.getDisplay(this).setCurrent(displayable);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
//文件名:LightForm.java
package light;
import javax.microedition.lcdui.*;
public class LightForm extends Form implements CommandListener {
StringItem si;
Command cmdOpen;
Command cmdClose;
Command cmdExit;
Display display;
public LightForm(LightMIDlet lm) {
super("手電筒");
si = new StringItem("手電筒狀態(tài):","打開(kāi)");
this.append(si);
display = Display.getDisplay(lm);
cmdOpen = new Command("打開(kāi)",Command.OK,1);
this.addCommand(cmdOpen);
cmdClose = new Command("關(guān)閉",Command.CANCEL,1);
this.addCommand(cmdClose);
cmdExit = new Command("退出",Command.EXIT,1);
this.addCommand(cmdExit);
setCommandListener(this);
boolean b;
b = display.flashBacklight(1000000);
if(b == false){
Alert alert = new Alert("手電筒","您的手機(jī)不支持該功能!",null,AlertType.INFO);
alert.setTimeout(3000);
display.setCurrent(alert);
}
}
public void commandAction(Command c, Displayable d) {
//關(guān)閉
if (c == cmdExit) {
// stop the MIDlet
LightMIDlet.quitApp();
}
//打開(kāi)
if(c == cmdOpen){
display.flashBacklight(1000000);
si.setText("打開(kāi)");
}
if(c == cmdClose){
display.flashBacklight(0);
si.setText("關(guān)閉");
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -