StringItemApperenceDemo.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:2k
源码类别:
J2ME
开发平台:
Java
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- public class StringItemApperenceDemo
- extends MIDlet
- implements CommandListener, ItemCommandListener {
- private Display display;
- private Form mainForm;
- private final static Command CMD_GO = new Command("Go", Command.ITEM, 1);
- private final static Command CMD_PRESS =
- new Command("Press", Command.ITEM, 1);
- private final static Command CMD_EXIT =
- new Command("Exit", Command.EXIT, 1);
- protected void startApp() {
- display = Display.getDisplay(this);
- mainForm = new Form("StringItem外观模式演示");
- StringItem item = new StringItem("Hyper-Link演示 ", "http://www.163.com", Item.HYPERLINK);
- item.setDefaultCommand(CMD_GO);
- item.setItemCommandListener(this);
- mainForm.append(item);
- item = new StringItem("Button演示", "按钮", Item.BUTTON);
- item.setDefaultCommand(CMD_PRESS);
- item.setItemCommandListener(this);
- mainForm.append(item);
- mainForm.addCommand(CMD_EXIT);
- mainForm.setCommandListener(this);
- display.setCurrent(mainForm);
- }
- public void commandAction(Command c, Item item) {
- if (c == CMD_GO) {
- String text = "正在连接...";
- Alert a = new Alert("URL", text, null, AlertType.INFO);
- display.setCurrent(a);
- } else if (c == CMD_PRESS) {
- String text = "您已经按下了按钮...";
- Alert a = new Alert("Action", text, null, AlertType.INFO);
- display.setCurrent(a);
- }
- }
- public void commandAction(Command c, Displayable d) {
- destroyApp(false);
- notifyDestroyed();
- }
- protected void destroyApp(boolean unconditional) {
- }
- protected void pauseApp() {
- }
- }