---
title: "J2ME高级界面实现页面之间的跳转"
author: "rayloo"
date: "2007-09-27T16:27:00Z"
tags: []
slug: "j2me"
draft: false
lastmod: "2007-09-27T16:27:00Z"
id: 1008892
url: "https://rayloo.iteye.com/blog/1008892"
---

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)packagetest;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjava.io.IOException;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Command;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.CommandListener;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Display;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Displayable;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Image;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.List;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.midlet.MIDlet;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.midlet.MIDletStateChangeException;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)/\*\*\*//\**  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)*  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)\*@authorleilu  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)*  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)\*/  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)publicclassMainPageextendsMIDletimplementsCommandListener  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//m\_cmdExit  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateCommandm\_cmdExit=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//m\_cmdOK  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateCommandm\_cmdOK=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//Display  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateDisplaydisplay=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//list  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateListlist=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateImageicon=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicMainPage()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)super();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedvoidstartApp()throwsMIDletStateChangeException  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//display  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display=Display.getDisplay(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//m\_cmdExit  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)m\_cmdExit=newCommand("Exit",Command.EXIT,1);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//m\_cmdOK  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)m\_cmdOK=newCommand("OK",Command.OK,1);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//创建图像  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)icon=Image.createImage("/Icon.png");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)catch(IOExceptione)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//TODOAuto-generatedcatchblock  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)e.printStackTrace();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//list  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list=newList("主界面",List.EXCLUSIVE);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list.append("FirstPage",icon);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list.append("Secondpage",icon);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//增加按钮  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list.addCommand(m\_cmdExit);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list.addCommand(m\_cmdOK);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//监听  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)list.setCommandListener(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//显示  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(list);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedvoidpauseApp()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedvoiddestroyApp(booleanarg0)throwsMIDletStateChangeException  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicvoidcommandAction(Commandc,Displayabled)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)Stringcmd=c.getLabel();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(cmd=="OK")  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)switch(((List)d).getSelectedIndex())  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)case0:  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)FirstPagefirst=newFirstPage(display,list);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(first);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)break;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)case1:  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)SecondPagesecond=newSecondPage(display,list);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(second);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)default:  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)break;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)elseif(cmd=="Exit")  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)destroyApp(false);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)catch(MIDletStateChangeExceptione)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)e.printStackTrace();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)notifyDestroyed();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)packagetest;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjava.io.IOException;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Command;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.CommandListener;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Display;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Displayable;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Form;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Image;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.List;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Ticker;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)publicclassFirstPageextendsFormimplementsCommandListener  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//TICKER\_TEXT滚动文字  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privatestaticfinalStringTICKER\_TEXT="这是一个滚动条的例子正在滚动，可以一直滚动除非有触发了停止事件";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//display  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateDisplaydisplay;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateTickerticker=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//m\_cmdBack  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateCommandm\_cmdBack=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//list  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateListlist=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicFirstPage(Displaydisplay,Displayablelist)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)super("FirstPage");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.list=(List)list;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.display=display;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)m\_cmdBack=newCommand("Back",Command.BACK,1);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)ticker=newTicker(TICKER\_TEXT);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.setTicker(ticker);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//增加图片  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)Imageicon=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)icon=Image.createImage("/Java.png");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)catch(IOExceptione)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)e.printStackTrace();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.append(icon);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//增加按钮  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.addCommand(m\_cmdBack);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.setCommandListener(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//显示FirstPage  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicvoidcommandAction(Commandc,Displayabled)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(m\_cmdBack==c)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(list);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)packagetest;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Alert;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.AlertType;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Command;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.CommandListener;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Display;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Displayable;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.Form;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.List;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)importjavax.microedition.lcdui.TextField;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)publicclassSecondPageextendsFormimplementsCommandListener  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//display  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateDisplaydisplay;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//Back  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateCommandm\_cmdBack;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//Alert  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateCommandm\_cmdAlert;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//list  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)privateListlist=null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicSecondPage(Displaydisplay,Displayablelist)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)super("Second");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.display=display;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.list=(List)list;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)m\_cmdBack=newCommand("Back",Command.BACK,1);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)m\_cmdAlert=newCommand("Alert",Command.SCREEN,1);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.append(newTextField("E\_mail","lulei@163.com",15,  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)TextField.EMAILADDR));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//增加按钮  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.addCommand(m\_cmdBack);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.addCommand(m\_cmdAlert);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.setCommandListener(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//显示Form屏幕  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(this);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicvoidcommandAction(Commandc,Displayabled)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(m\_cmdAlert==c)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//创建要显示的图标  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//创建一个Alert屏幕对象，要显示的图标为img  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)Alertinfo=newAlert("ThisisaAlertExample");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)info.setType(AlertType.INFO);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//设置显示时间  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//info.setTimeout(Alert.FOREVER);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)info.setTimeout(3000);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//显示Alert屏幕  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)display.setCurrent(info);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(m\_cmdBack==c)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...