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

📄 imageitem_test.java

📁 j2me图像显示程序
💻 JAVA
字号:
package src;

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

public class ImageItem_Test extends MIDlet implements CommandListener{
	
	private Display ds;
	private Form form;
	private ImageItem img;
	private Command cmd_exit = new Command("退出",Command.EXIT,1);
	private Command cmd_explorer = new Command("Explorer",Command.SCREEN,1);
	private int flag = 1;
	

	public ImageItem_Test() {
		// TODO 自动生成构造函数存根
		
	}

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

	}

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

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO 自动生成方法存根
		ds = Display.getDisplay(this);
		form = new Form("Image Explorer");
		try {
			img = new ImageItem("MYImage",Image.createImage("/res/image4.png"), ImageItem.LAYOUT_LEFT|ImageItem.LAYOUT_NEWLINE_BEFORE, "Image explorer");
		} catch (java.io.IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		form.append(img);
		flag=1;
		form.addCommand(cmd_exit);
		form.addCommand(cmd_explorer);
		form.setCommandListener(this);
		ds.setCurrent(form);

	}

	public void commandAction(Command c, Displayable d) {
		// TODO 自动生成方法存根
		if(c==cmd_exit)
		{
			destroyApp(false);
			notifyDestroyed();
		}
		if(c==cmd_explorer)
		{
			if(flag==1)
			{
				try
				{
					img.setImage(Image.createImage("/res/image3.png"));
				}
				catch(java.io.IOException e)
				{}
				}
			else
			{
				try
				{
					img.setImage(Image.createImage("/res/image4.png"));
				}
				catch(java.io.IOException e){}
			}
			flag = flag*(-1);
		}
		
	}

}

⌨️ 快捷键说明

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