?? textbox_alert.java
字號:
/*
* 顯示一個Alert的屏幕
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class TextBox_Alert extends MIDlet implements CommandListener {
private Command exitCommand,alertCommand;
private TextBox tb;
public TextBox_Alert() {
exitCommand = new Command("Exit", Command.EXIT, 1);
alertCommand = new Command("Alert", Command.SCREEN, 1);
tb = new TextBox("Alert MIDlet", "Alert Example!", 15, 0);
tb.addCommand(exitCommand);
tb.addCommand(alertCommand);
tb.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(tb);
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0){
}
public void commandAction(Command c, Displayable d) {
if(d == tb && c == alertCommand){
Image img;
try{
img = Image.createImage("/Icon.png");
}
catch(java.io.IOException e){
img = null;
}
Alert info = new Alert("Alert","This is a Alert Example!",img ,AlertType.INFO);
info.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(info,tb);
//也可以使用 Display.getDisplay(this).setCurrent(info);返回前一個畫面
}
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -