TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
- /*
- * 显示一个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();
- }
- }
- }
复制代码
源码下载:http://203.93.208.26/kj/cwb/dir7/TextBox_Alert.zip |
|