⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alertdemo.java~3~

📁 J2ME高级用户界面的学习代码
💻 JAVA~3~
字号:
//AlertDemo.javaimport javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;public class AlertDemo extends MIDlet implements CommandListener{  private final static Command CMD_EXIT = new Command("EXIT",Command.EXIT,1);  private Alert alert;  private Form form;  private final int timeout = 10000;  public AlertDemo()  {    try    {      alert = new Alert("AlertDemo","Information Alert Running",Image.createImage("/information.png"),AlertType.INFO);      alert.setTimeout(timeout);      Gauge indicator = createIndicator(timeout);      alert.setIndicator(indicator);    }    catch(java.io.IOException e)    {      System.out.println(e.toString());    }    form = new Form("Next Screen");    form.append("Alert has done!");    form.addCommand(CMD_EXIT);    form.setCommandListener(this);  }  protected void startApp()  {    Display.getDisplay(this).setCurrent(alert,form);  }  protected void destroyApp(boolean unconditional){}  protected void pauseApp(){}  public void commandAction(Command c,Displayable d)  {    if(c == CMD_EXIT)    {      destroyApp(false);      notifyDestroyed();    }  }  private Gauge createIndicator(int maxValue)  {    if(maxValue == Alert.FOREVER)    {      return new Gauge(null,false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);    }    final int max = maxValue/1000;//指示器的最大值    final Gauge indicator = new Gauge(null,false,max,0);    new Thread()    {      public void run()      {        int value = 0;        while(value < max)        {          indicator.setValue(value);          ++value;          try          {            Thread.sleep(1000);          }          catch(InterruptedException ie){}        }      }    }.start();    return indicator;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -