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

📄 imageitemdemo.java

📁 《精通JAVA手机游戏与应用程序设计》随书光盘
💻 JAVA
字号:

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

public class ImageItemDemo extends MIDlet implements CommandListener {

	private Command exitCommand = new Command("退出", Command.EXIT, 1);

	private Form mainForm;

	private ImageItem pngItem_1,pngItem_2;

	public ImageItemDemo() {
		mainForm = new Form("ImageItem");
	}

	protected void startApp() {

		mainForm.append("显示各种类型的ImageItem");

		try {
			//程序创建时添加默认布局的图像
			pngItem_1 = new ImageItem("默认图像控件", Image.createImage("/Image.png"),
					Item.LAYOUT_DEFAULT, "小猪图片");
			pngItem_2 = new ImageItem("默认图像控件", Image.createImage("/Image.png"),
					Item.LAYOUT_2|Item.LAYOUT_EXPAND|Item.LAYOUT_NEWLINE_BEFORE, "小猪图片");
		} catch (Exception e) {
			System.out.println("load image error");
		}

		mainForm.append(pngItem_1);
		mainForm.append(pngItem_2);

		mainForm.addCommand(exitCommand);
		mainForm.setCommandListener(this);

		Display.getDisplay(this).setCurrent(mainForm);
	}

	public void commandAction(Command c, Displayable s) {
		if (c == exitCommand) {
			destroyApp(false);
			notifyDestroyed();
		}
	}

	protected void destroyApp(boolean unconditional) {
	}

	protected void pauseApp() {
	}
}

⌨️ 快捷键说明

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