隨筆-348  評論-598  文章-0  trackbacks-0
          這個跟其他J2ME的開發一樣,稍微提一下做個備份。
          /**
           * MidletSample.java
           * 
           * (c) Research In Motion Limited, 2003-2004. Confidential and proprietary.
           
          */




          import java.util.*;
          import java.io.*;
          import javax.microedition.midlet.*;
          import javax.microedition.lcdui.*;

          import java.lang.*;

          /**
           * An Example MIDlet.
           * The application must extend the MIDlet class to allow the application management software to control the MIDlet.
           
          */

          public class MidletSample extends MIDlet implements CommandListener
          {
              
          private Display display;
              
          /**
               * <p>The default constructor. Say hello world
               
          */

              
          public MidletSample()
              
          {

                  
          //create a simple screen
          //        Form form = new Form("Hello Form");
          //        form.append( new StringItem( "Hello World", null ) );
          //        Command back = new Command("Back", Command.BACK, 0);
          //        form.addCommand(back);
          //        form.setCommandListener(this);
          //        Display.getDisplay(this).setCurrent(form);
                  this.display = Display.getDisplay(this);
                  MainCanvas main 
          = new MainCanvas(this);
                  Show(main);
              }

              
              
          public void Show(Displayable d)
              
          {
                  display.setCurrent(d);
              }


              
          /**
               * <p>Signals the MIDlet that it has entered the Active state.
               
          */

              
          public void startApp()
              
          {
                  
              }


              
          /**
               * <p>Signals the MIDlet to stop and enter the Pause state.
               
          */

              
          public void pauseApp()
              
          {
              }


              
          /**
               * <p>Signals the MIDlet to terminate and enter the Destroyed state.
               * 
          @param unconditional When set to true, the MIDlet must cleanup and release all resources. Otherwise, the MIDlet may
               * throw a MIDletStateChangeException to indicate it does not want to be destroyed at this time.
               
          */

              
          public void destroyApp(boolean unconditional)
              
          {
              }


              
          public void commandAction(Command c, Displayable d) {
                  
          // TODO Auto-generated method stub
                  if(c.getCommandType() == Command.BACK)
                      
          this.notifyDestroyed();
                  
              }


          }

          import javax.microedition.lcdui.Alert;
          import javax.microedition.lcdui.Canvas;
          import javax.microedition.lcdui.Graphics;


          public class MainCanvas extends Canvas {

              
          private MidletSample midletSample = null;
              
          public MainCanvas(MidletSample midletSample)
              
          {
                  
          this.midletSample = midletSample;
              }

              
              
          protected void paint(Graphics g) {
                  
          // TODO Auto-generated method stub
                  
              }


              
          public void keyPressed(int key){
                  Alert al 
          = new Alert(String.valueOf(key));
                  al.setTimeout(
          5000);
                  midletSample.Show(al);
              }

          }

          這個程序同時也是用來測試鍵值的。

          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2009-12-13 12:20 TiGERTiAN 閱讀(1333) 評論(2)  編輯  收藏 所屬分類: J2MEBlackBerry

          評論:
          # re: BlackBerry軟件開發入門--MIDlet開發 2009-12-14 21:34 | 仁心博客
          真是很高深呢  回復  更多評論
            
          # re: BlackBerry軟件開發入門--MIDlet開發 2010-10-27 20:17 | xu
          你好,請問能不能提供一些基礎的BlackBerry軟件開發的資料?
          萬分感謝
          Email xfy678@163.com  回復  更多評論
            
          主站蜘蛛池模板: 越西县| 乐昌市| 文成县| 潞城市| 吴忠市| 辽宁省| 梅州市| 明光市| 油尖旺区| 新营市| 宾川县| 蒙城县| 玛纳斯县| 营山县| 九龙县| 晋城| 泸西县| 阿拉善左旗| 云龙县| 常宁市| 平陆县| 永安市| 彩票| 榆社县| 盘山县| 河东区| 许昌县| 宜黄县| 定南县| 佛学| 百色市| 修水县| 文水县| 富宁县| 东至县| 且末县| 泌阳县| 连云港市| 色达县| 根河市| 望江县|