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

📄 stringitemtest.java

📁 微型JAVA人编写的J2ME教材! 中带的原代码!简单易懂
💻 JAVA
字号:
//StringItemTest.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class StringItemTest extends MIDlet 
implements CommandListener,ItemStateListener, ItemCommandListener
{
	private Display display;
	Command commit ;
	public StringItemTest ()
	{
		display = Display.getDisplay(this);
	}
	public void startApp()
	{
		commit = new Command("Commit",Command.SCREEN,1) ;
		Form f = new Form("Form与StringItem") ;
		f.append("String 1") ;
		f.append("String 2") ;
		StringItem item1 = new StringItem("Label ","大众日报最新消息",Item.PLAIN);
		StringItem item2 = new StringItem("Button ","确定",Item.BUTTON);
		StringItem item3 = new StringItem("hyper-link ","点这里查看详情",Item.HYPERLINK);
		Command cmd2 = new Command( "OK", Command.ITEM, 1 );
		item2.setDefaultCommand( cmd2 );
		item2.setItemCommandListener( this );
		Command cmd3 = new Command( "Detail", Command.ITEM, 1 ); 
		item3.setDefaultCommand( cmd3 );
		item3.setItemCommandListener( this );
		f.append( item1 );
		f.append( item2 );
		f.append( item3 );
		f.addCommand(commit) ;
		f.addCommand( cmd2 );
		f.addCommand( cmd3 );
		f.setCommandListener(this) ;
		f.setItemStateListener(this) ;
		display.setCurrent(f) ;
	}
	public void pauseApp()
	{ }
	public void destroyApp(boolean unconditional)
	{ }
	public void commandAction(Command c,Displayable s)
	{
		Form tmp = (Form) s ;
		for(int i = 0 ; i < tmp.size() ; i++)
		{
			StringItem si = (StringItem) tmp.get(i) ;
			System.out.println(si.getText());
		}
	}
	public void itemStateChanged(Item item)
	{}
	public void commandAction(Command c, Item item )
	{
		System.out.println(item.getLabel());
	}

}

⌨️ 快捷键说明

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