J2ME学习笔记(三)-----学习MIDlets

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'; mso-bidi-font-size: 12.0pt">处理MIDlets MEspace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

1.MEs New Roman'">       MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">是使用MIDPMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">特征和CLDCMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">配置的MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">应用

1).MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">是打包成JAD(JAVAMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">描述符)MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">文件的JavaMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">类文件

2).MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">运行在已安装于MIDPMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">设备上的Application ManageMEnt Software(MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">应用管理软件AMS).AMSMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">提供KVMMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">和MIDletsMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的环境

3).MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">是在支持CLDCMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">和MIDPMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的手持设备中使用.

 

2.MEs New Roman'">       MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的生命周期(MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">图)

 

3.MEs New Roman'">       MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">开发MIDletsMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">实例

1).MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">任务陈述-----SaveMyMoneyMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">移动银行应用的第一个屏幕上要显示的消息为”WelcoME to    SaveMyMoney Bank!”,MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">屏幕顶部有一个显示消息"WelcoME to the World of Mobile Banking!"MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的滚动文本;

MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">第二个屏幕上要显示的消息为"Dear CustoMEr,        , You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office."MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">屏幕顶部有一个显示消息"Note: Your PIN number has been sent to you at your mailing address."MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的滚动文本

 

2).MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">代码如下-----

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

//MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">需要实现lcduiMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">类中的CommandListenerMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">接口

public class MB extends MIDlet impleMEnts CommandListener

{

       //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">用DisplayMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">类管理显示和用户的输入

       Display display;

       Form form1;

       Form form2;

       //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">定义两个滚动条ticker1,ticker2

       Ticker ticker1;

       Ticker ticker2;

       static final Command okCommand = new Command("Info",Command.OK,1);

       static final Command backCommand = new Command("Back",Command.BACK,0);

       static final Command exitCommand = new Command("Exit", Command.STOP, 2);

       public MB()

       {

       }

       public void startApp() throws MIDletstateChangeException

       {

              ticker1 = new Ticker("WelcoME to the World of Mobile Banking!");

              ticker2 = new Ticker("Note: Your PIN number has been sent to you at your mailing address.");

             

              display = Display.getDisplay(this);

              form1 = new Form("SaveMyMoney");

              form2 = new Form("CUSTOMER CARE");

              StringItem strItem = new StringItem("WelcoME to    SaveMyMoney Bank!", "");

              StringItem strItem1 = new StringItem("Dear CustoMEr,        ", "You can view your personal account information by entering your PIN number and sending it to the number 9002. If you have not received the PIN number, please contact us at our Head Office.");

              form1.append(strItem);

              form2.append(strItem1);

              //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">把命令加入到屏幕,MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">第一个屏幕的左软键是Exit,MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">右软键是OK

              form1.addCommand(exitCommand);

              form1.addCommand(okCommand);

              //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">监听

              form1.setCommandListener(this);

              form1.setTicker(ticker1);

              //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">设置主屏幕的当前显示为Form1

              display.setCurrent(form1);

       }

       public void pauseApp()

       {

       }

       public void destroyApp(boolean unconditional)

       {

              notifyDestroyed();

       }

       public void showForm1()

       {

              form1.addCommand(exitCommand);

              form1.addCommand(okCommand);

              form1.setCommandListener(this);

              display.setCurrent(form1);

       }

       public void showForm2()

       {

              form2.addCommand(exitCommand);

              form2.addCommand(backCommand);

              form2.setCommandListener(this);

              form2.setTicker(ticker2);

              display.setCurrent(form2);

      

       }

       public void commandAction(Command cmd, Displayable displayable)

       {

              String label = cmd.getLabel();

              if (label.equals("Exit"))

              {

                     //MEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">调用撤消MIDletMEs New Roman'; mso-hansi-font-family: 'TiMEs New Roman'">的动作并退出此应用

              destroyApp(true);

              }

              else if (label.equals("Back"))

              {

// go back to Form1

                     showForm1();

              }

              else

              {

                     showForm2();

              }

       }

}

 测试效果如下:

 

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值