package com.brj.test;
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.Item;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
* StringItem练习例题
* @author Administrator
*
*/
public class StringItemTest extends MIDlet implements CommandListener {
private Display display;
private Command exit;
private Form mainFace;
private StringItem plain;//普通的
private StringItem button;//按钮状的
private StringItem hyperLink;//超级链接型的
public StringItemTest() {
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 0);
mainFace = new Form("");
plain = new StringItem("plain", "plain", Item.PLAIN);
button = new StringItem("button", "button",Item.BUTTON);
hyperLink = new StringItem("hyperLink", "hyperLink", Item.HYPERLINK);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
mainFace.addCommand(exit);
mainFace.append(plain);
mainFace.append(button);
mainFace.append(hyperLink);
mainFace.setCommandListener(this);
display.setCurrent(mainFace);
}
public void commandAction(Command c, Displayable d) {
if(c == exit){
try {
this.destroyApp(false);
} catch (MIDletStateChangeException e) {
e.printStackTrace();
}
this.notifyDestroyed();
}
}
}