随笔-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 阅读(1297) 评论(2)  编辑  收藏 所属分类: J2MEBlackBerry

评论:
# re: BlackBerry软件开发入门--MIDlet开发 2009-12-14 21:34 | 仁心博客
真是很高深呢  回复  更多评论
  
# re: BlackBerry软件开发入门--MIDlet开发 2010-10-27 20:17 | xu
你好,请问能不能提供一些基础的BlackBerry软件开发的资料?
万分感谢
Email xfy678@163.com  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: