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

📄 stringitemapperencedemo.java

📁 J2ME常用控件使用的例子 Eclipse写的 练手用的
💻 JAVA
字号:
package stringitem;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
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.ItemCommandListener;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;

public class StringItemApperenceDemo extends MIDlet implements CommandListener, ItemCommandListener {
	private Display display;
	private Form form;
	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);

	public StringItemApperenceDemo() {
		// TODO 自动生成构造函数存根
		display = Display.getDisplay(this);
		form = new Form("StringItem ApperanceMode Demo");
		// 超级链接StringItem
		StringItem item = new StringItem("Hyper-Link Demo","http://www.sina.com",Item.HYPERLINK);
		item.setDefaultCommand(CMD_GO);  // 字符串超级链接组件设置默认软键为GO软键
		item.setItemCommandListener(this);  // 向组件添加软键事件监听器
		form.append(item);
		// 按钮StringItem
		item = new StringItem("Buttom Demo", "Button", Item.BUTTON);
		item.setDefaultCommand(CMD_PRESS);  // 字符串按钮组件设置默认软键为Press软键
		item.setItemCommandListener(this);
		form.append(item);
		form.addCommand(CMD_EXIT);
		form.setCommandListener(this);  // 向表单添加软键时间侦听器
	}

	protected void destroyApp(boolean arg0){
		// TODO 自动生成方法存根

	}

	protected void pauseApp() {
		// TODO 自动生成方法存根

	}

	protected void startApp(){
		// TODO 自动生成方法存根
		display.setCurrent(form);
	}

	//侦听组件的软键事件
	public void commandAction(Command c, Item item){
		if(c == CMD_GO){
			String text = "Linking";
			Alert a = new Alert("URL",text,null,AlertType.INFO);
			display.setCurrent(a);
		}else if(c == CMD_PRESS){
			String text = "You have pressed the StringItem button...";
			Alert a = new Alert("Action",text,null,AlertType.INFO);
			display.setCurrent(a);
		}
	}
	
	public void commandAction(Command c, Displayable d){
		destroyApp(false);
		notifyDestroyed();
	}

}

⌨️ 快捷键说明

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