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

📄 imageitemdemo.java

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

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

public class ImageItemDemo extends MIDlet implements ItemCommandListener,CommandListener {

	private Display display;
	private Form form;
	private Command cmdExit = new Command("退出",Command.SCREEN,1);
	private Command cmdImage1 = new Command("图片1",Command.SCREEN,1);
	private Command cmdImage2 = new Command("图片2",Command.SCREEN,1);
	public ImageItemDemo() {
		// TODO 自动生成构造函数存根
		display = Display.getDisplay(this);
		Image img = null;
		try{
			img = Image.createImage("/res/Vincent.png");
		}catch(Exception e){
		}
		form = new Form("ImageItem Demo");
		form.append(img);
		ImageItem Item1 = new ImageItem("图片1",img,Item.LAYOUT_CENTER|Item.LAYOUT_NEWLINE_BEFORE,"ImageItem 1",Item.BUTTON);
		Item1.setDefaultCommand(cmdImage1);
		Item1.setItemCommandListener(this);
		form.append(Item1);
		ImageItem Item2 = new ImageItem("图片2",img,Item.LAYOUT_RIGHT|Item.LAYOUT_NEWLINE_BEFORE,"ImageItem 2",Item.HYPERLINK);
		Item2.setDefaultCommand(cmdImage2);
		Item2.setItemCommandListener(this);
		form.append(Item2);
		form.addCommand(cmdExit);
		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 i){
		System.out.println(c.getLabel());
		System.out.println(i.getLabel());
	}

	public void commandAction(Command c,Displayable d){
		if(c == cmdExit){
			this.destroyApp(false);
			notifyDestroyed();
		}
	}

}

⌨️ 快捷键说明

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