⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0027d1bc3d99001b17aef781993f096e

📁 《J2ME实用教程》 源文件下载 本书没有仅仅局限于J2ME单机游戏的开发
💻
字号:

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


public class StringItemDemo
    extends MIDlet
    implements CommandListener, ItemCommandListener {

    private Display display;
    private Form mainForm;
    private final static Command httpCommand = new Command("Go", Command.ITEM, 1);
    private final static Command okCommand =
	    new Command("Press", Command.ITEM, 1);
    private final static Command exitCommand =
	    new Command("Exit", Command.EXIT, 1);
    
   
    protected void startApp() {
        display = Display.getDisplay(this);

        mainForm = new Form("String Item Demo");
        
        StringItem item = new StringItem("标题: ",  "StringItem具体内容");
        mainForm.append(item);
        
        item = new StringItem("Hyper-Link ", "http://www.sina.com.cn/sports", Item.HYPERLINK);
        item.setDefaultCommand(httpCommand);
        item.setItemCommandListener(this);
        mainForm.append(item);
        
        item = new StringItem("", "确定", Item.BUTTON);
        item.setDefaultCommand(okCommand);
        item.setItemCommandListener(this);
        mainForm.append(item);
        
        mainForm.addCommand(exitCommand);
        mainForm.setCommandListener(this);
        
        display.setCurrent(mainForm);
    }

    public void commandAction(Command c, Item item) {
        if (c == httpCommand) {
            String text = "正在连接网络.....";
            Alert a = new Alert("URL", text, null, AlertType.INFO);
            display.setCurrent(a);
        } else if (c == okCommand) {
            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() {
    }            
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -