Tuesday, October 20, 2009
7:35 AM ●

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ex05 extends MIDlet implements CommandListener
{
Display d ;
TextBox txtinformation;
String[] stringElements={"zz","xx","cc"};
Command cmdExit, cmdNextInfo;
int counter=0;

public void startApp()
{
txtinformation = new TextBox("Information",stringElements[counter],500,TextField.ANY TextField.UNEDITABLE);
cmdExit = new Command("Exit",Command.EXIT,0);
cmdNextInfo = new Command("Next",Command.SCREEN,1);

txtinformation.addCommand(cmdExit);
txtinformation.addCommand(cmdNextInfo);
txtinformation.setCommandListener(this);

d = Display.getDisplay(this);
d.setCurrent(txtinformation);
}
public void commandAction(Command cmd, Displayable d)
{
if(cmd==cmdExit)
{
notifyDestroyed();
}
if(cmd==cmdNextInfo)
{
txtinformation.setString(stringElements[++counter]);
if(counter==2)
counter=0;
}
}
public void pauseApp()
{
}
public void destroyApp(boolean c)
{
}
}

------

( YOUARENOTALONE. )