国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

J2ME學習筆記(3)—初次接觸MIDlets

2019-11-17 06:23:43
字體:
來源:轉載
供稿:網友

  1.MIDlet是使用MIDP特征和CLDC配置的MIDlet應用
  1).MIDlet是打包成JAD(java描述符)文件的Java類文件
  
  2).MIDlet運行在已安裝于MIDP設備上的application Management Software(應用治理軟件AMS).AMS提供KVM和MIDlets的環境
  
  3).MIDlet是在支持CLDC和MIDP的手持設備中使用.
  
  2.MIDlet的生命周期
  
  3.開發MIDlets實例
  1).任務陳述-----SaveMyMoney移動銀行應用的第一個屏幕上要顯示的消息為”Welcome to  SaveMyMoney Bank!”,屏幕頂部有一個顯示消息"Welcome to the World of Mobile Banking!"的滾動文本;
  
  第二個屏幕上要顯示的消息為"Dear Customer,    , You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office."屏幕頂部有一個顯示消息"Note: Your PIN number has been sent to you at your mailing address."的滾動文本
  
  2).代碼如下-----
  
  import javax.microedition.midlet.*;
  
  import javax.microedition.lcdui.*;
  
  //需要實現lcdui類中的CommandListener接口
  
  public class MB extends MIDlet implements CommandListener
  
  {
  
      //用Display類治理顯示和用戶的輸入
  
      Display display;
  
      Form form1;
  
      Form form2;
  
      //定義兩個滾動條ticker1,ticker2
  
      Ticker ticker1;
  
      Ticker ticker2;
  
      static final Command okCommand = new Command("Info",Command.OK,1);
  
      static final Command backCommand = new Command("Back",Command.BACK,0);
  
      static final Command exitCommand = new Command("Exit", Command.STOP, 2);
  
      public MB()
  
      {
  
      }
  
      public void startApp() throws MIDletStateChangeException
  
      {
  
         ticker1 = new Ticker("Welcome to the World of Mobile Banking!");
  
         ticker2 = new Ticker("Note: Your PIN number has been sent to you at your mailing address.");
  
         display = Display.getDisplay(this);
  
         form1 = new Form("SaveMyMoney");
  
         form2 = new Form("CUSTOMER CARE");
  
         StringItem strItem = new StringItem("Welcome to  SaveMyMoney Bank!", "");
  
         StringItem strItem1 = new StringItem("Dear Customer,    ", "You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office.");
  
         form1.append(strItem);
  
         form2.append(strItem1);
  
         //把命令加入到屏幕,第一個屏幕的左軟鍵是Exit,右軟鍵是OK
  
         form1.addCommand(exitCommand);
  
         form1.addCommand(okCommand);
  
         //監聽
  
         form1.setCommandListener(this);
  
         form1.setTicker(ticker1);
  
         //設置主屏幕的當前顯示為Form1
  
         display.setCurrent(form1);
  
      }
  
      public void pauseApp()
  
      {
  
      }
  
      public void destroyApp(boolean unconditional)
  
      {
  
         notifyDestroyed();
  
      }
  
      public void showForm1()
  
      {
  
         form1.addCommand(exitCommand);
  
         form1.addCommand(okCommand);
  
         form1.setCommandListener(this);
  
         display.setCurrent(form1);
  
      }
  
      public void showForm2()
  
      {
  
         form2.addCommand(exitCommand);
  
         form2.addCommand(backCommand);
  
         form2.setCommandListener(this);
  
         form2.setTicker(ticker2);
  
         display.setCurrent(form2);
  
      }
  
      public void commandAction(Command cmd, Displayable displayable)
  
      {
  
         String label = cmd.getLabel();
  
         if (label.equals("Exit"))
  
         {
  
             //調用撤消MIDlet的動作并退出此應用
  
         destroyApp(true);
  
         }
  
         else if (label.equals("Back"))
  
         {
  
  // go back to Form1
  
             showForm1();
  
         }
  
         else
  
         {
            showForm2();
  
         }
      }
  }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贺州市| 扶余县| 合川市| 万盛区| 通化县| 邵阳县| 高要市| 三原县| 榆社县| 雅江县| 安阳县| 屏东县| 徐州市| 梁河县| 绥棱县| 济阳县| 樟树市| 安多县| 宜都市| 弋阳县| 襄城县| 抚松县| 志丹县| 巧家县| 新邵县| 特克斯县| 滁州市| 原平市| 茌平县| 乐安县| 兰溪市| 陇西县| 揭东县| 宁德市| 江津市| 民权县| 天水市| 望城县| 韩城市| 八宿县| 和平区|