隨筆-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 閱讀(1328) 評論(2)  編輯  收藏 所屬分類: J2ME 、BlackBerry

          評論:
          # re: BlackBerry軟件開發入門--MIDlet開發 2009-12-14 21:34 | 仁心博客
          真是很高深呢  回復  更多評論
            
          # re: BlackBerry軟件開發入門--MIDlet開發 2010-10-27 20:17 | xu
          你好,請問能不能提供一些基礎的BlackBerry軟件開發的資料?
          萬分感謝
          Email xfy678@163.com  回復  更多評論
            
          主站蜘蛛池模板: 青冈县| 乌拉特后旗| 松江区| 麻阳| 黄骅市| 云林县| 邳州市| 西安市| 阆中市| 萨迦县| 栖霞市| 德格县| 日土县| 开远市| 无锡市| 仪征市| 卢龙县| 南通市| 库伦旗| 和田县| 磴口县| 姚安县| 东源县| 咸宁市| 汉寿县| 周宁县| 永年县| 会同县| 湘阴县| 融水| 皮山县| 德安县| 临泽县| 驻马店市| 阿荣旗| 富阳市| 浦北县| 毕节市| 集贤县| 修水县| 长岛县|