隨筆-348  評(píng)論-598  文章-0  trackbacks-0
          這個(gè)跟其他J2ME的開(kāi)發(fā)一樣,稍微提一下做個(gè)備份。
          /**
           * 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);
              }

          }

          這個(gè)程序同時(shí)也是用來(lái)測(cè)試鍵值的。

          ---------------------------------------------------------
          專注移動(dòng)開(kāi)發(fā)

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

          評(píng)論:
          # re: BlackBerry軟件開(kāi)發(fā)入門--MIDlet開(kāi)發(fā) 2009-12-14 21:34 | 仁心博客
          真是很高深呢  回復(fù)  更多評(píng)論
            
          # re: BlackBerry軟件開(kāi)發(fā)入門--MIDlet開(kāi)發(fā) 2010-10-27 20:17 | xu
          你好,請(qǐng)問(wèn)能不能提供一些基礎(chǔ)的BlackBerry軟件開(kāi)發(fā)的資料?
          萬(wàn)分感謝
          Email xfy678@163.com  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 祁东县| 阳原县| 通道| 大埔县| 长丰县| 宜城市| 香港| 东阿县| 南昌县| 宜昌市| 涡阳县| 乌拉特中旗| 突泉县| 鄯善县| 上犹县| 巴青县| 合作市| 珠海市| 鹿泉市| 茌平县| 砚山县| 治多县| 普兰县| 拉孜县| 凤翔县| 墨玉县| 咸宁市| 白河县| 宜城市| 文成县| 永城市| 沁阳市| 乡城县| 潼关县| 淮阳县| 辰溪县| 峡江县| 墨玉县| 安国市| 桦南县| 张家川|