I'd like to give you a example for your request.
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public final class TestStringItemMIDlet extends MIDlet implements CommandListener, ItemCommandListener {
/** Soft button for exiting the demo. */
Form main_form = new Form("TestStringItem");
private Command exitCommand = new Command("Exit", Command.EXIT, 1);
private Command itemCommand = new Command("Item Command", Command.ITEM, 1);
StringItem normalItem = new StringItem("Plain:","World",Item.PLAIN);
StringItem commandItem = new StringItem("Button:","World",Item.BUTTON);
public void startApp() {
main_form.append(normalItem);
main_form.append(commandItem);
main_form.addCommand(exitCommand);
main_form.setCommandListener (this);
Display.getDisplay(this).setCurrent(main_form);
commandItem.setDefaultCommand(itemCommand);// add Command to Item.
commandItem.setItemCommandListener(this);// set item command listener
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();
}
}
public void commandAction(Command c, Item item)
{
if(c == itemCommand)
{
normalItem.setText("OK! Item command clicked!");
}
}
}