日期:2014-05-20  浏览次数:20770 次

我编写了一个特别简单的J2me程序,但无法装到手机里,请教呀!
我编写了一个可别简单的j2me的程序, 就想放在我的手机里试试,导出了jad文件,在手机中进行安装,在安装的最后提示文件无效,我的手机是n72,大家说说怎么回事呀!



以下是代码,代码在wtk自带的模拟运行正常, 大家说说怎么回事呀!




import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class MessageUI extends MIDlet implements CommandListener ,ItemStateListener {
private Display dis;
/***********************欢迎界面组件**********************************/
private Form welFrm ;
private Command comWelWriteMsg;
private Command comWelExit;
private ImageItem imgIt;
/***********************短息编辑界面组件**********************************/
private Form ediFrm;
private TextField tfMsgEdi;
private Command comTbDel;
private Command comTbBack;
private Command comTbSend;
/***********************短息发送界面组件**********************************/
private Form sendfrm;
private Command comSendBack;
private Command comSendSure;
private TextField tfSend;
private Alert at;


public MessageUI() {
/***********************欢迎界面组件初始化**********************************/
welFrm = new Form("欢迎使用");
Image img = null;
try{
img = Image.createImage("/img5.png");
}catch(Exception e){
e.printStackTrace();
}
imgIt = new ImageItem("欢迎使用短信发送系统",img,Item.LAYOUT_CENTER,"图片未能正确读取");
comWelWriteMsg = new Command("写短信",Command.SCREEN,1);
comWelExit = new Command("返回",Command.EXIT,1);



/***********************短息编辑界面组件初始化**********************************/
ediFrm = new Form("短息编辑界面");
tfMsgEdi = new TextField("请编辑短息内容","",255,TextField.ANY);
//tfMsgEdi.setLayout(Item.LAYOUT_VCENTER );
tfMsgEdi.setPreferredSize(ediFrm.getWidth(), ediFrm.getHeight());
comTbBack = new Command("返回",Command.BACK,1);
comTbDel = new Command("删除",Command.BACK,1);
comTbSend =new Command("发送",Command.SCREEN,1);

/***********************短息发送界面组件初始化**********************************/
sendfrm = new Form("确认发送");
tfSend = new TextField("请输入号码:","",255,TextField.ANY);
comSendBack = new Command("返回",Command.BACK,1);
comSendSure = new Command("确定",Command.SCREEN,1);
at = new Alert("发送成功");




}

protected void startApp() throws MIDletStateChangeException {
dis = Display.getDisplay(this);
/***********************欢迎界面组件组装**********************************/
dis.setCurrent(welFrm);
welFrm.append(imgIt);
welFrm.addCommand(comWelWriteMsg);
welFrm.addCommand(comWelExit);
/***********************短息编辑界面组件组装**********************************/
ediFrm.append(tfMsgEdi);
ediFrm.addCommand(comTbBack);
ediFrm.addCommand(comTbSend);

/***********************短息发送界面组件组装**********************************/
sendfrm.append(tfSend);
sendfrm.addCommand(comSendBack);
sendfrm.addCommand(comSendSure);



/*************************注册监听器****************************************/
welFrm.setCommandListener(this);
ediFrm.setCommandListener(this);

ediFrm.setItemStateListener(this);