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

📄 imageitems.java

📁 运用HTTPCONNECTION做一个简单的聊天程序
💻 JAVA
字号:
package datagram003packet;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.*;//use the ui
public class ImageItems extends Form implements CommandListener, ItemCommandListener {

	private ImageItem imageItem[]=new ImageItem[6];
	private Display display;
	private Server server;
	//private Form form;
	private Command backCommand;
	private Command []command=new Command[6];
	private String img_path;
	
     public ImageItems(Display display,Server server)
     {
    	 super("Please Select Your Image");
    	 //this.form=form;
    	 this.display=display;
    	 this.server=server;
    	 backCommand=new Command("Back",Command.EXIT,1);
    	 for(int i=0;i<imageItem.length;i++)
    	 {
    		 imageItem[i]=new ImageItem(null,null,ImageItem.LAYOUT_LEFT,"无法显示图片");
    		 command[i]=new Command("Select"+i,Command.OK,1);
    		 imageItem[i].setDefaultCommand(command[i]);
    	 }
    	
    	 imageItem[0].setImage(getImages("/7.PNG"));
    	 
    	 this.append(imageItem[0]);
    	// this.addCommand(command[0]);
    	 imageItem[0].setItemCommandListener(this);
    	 
    	 imageItem[1].setImage(getImages("/8.PNG"));
    	 
    	 this.append(imageItem[1]);
    	 imageItem[1].setItemCommandListener(this);
    	// this.addCommand(command[1]);
    	 
    	 imageItem[2].setImage(getImages("/9.PNG"));
    	
    	 this.append(imageItem[2]);
    	 imageItem[2].setItemCommandListener(this);
    	 //this.addCommand(command[2]);
    	 
    	 imageItem[3].setImage(getImages("/10.PNG"));
    	
    	 this.append(imageItem[3]);
    	 imageItem[3].setItemCommandListener(this);
    	 //this.addCommand(command[3]);
    	 
    	 imageItem[4].setImage(getImages("/11.PNG"));
    
    	 this.append(imageItem[4]);
    	 imageItem[4].setItemCommandListener(this);
    	 //this.addCommand(command[4]);
    	 
    	 imageItem[5].setImage(getImages("/12.PNG"));
    	
    	 this.append(imageItem[5]);
    	 imageItem[5].setItemCommandListener(this);
    	 //this.addCommand(command[5]);
    	 
    	 this.addCommand(backCommand);
    	 this.setCommandListener(this);
    	 
    	
    	
    	 
    	 
     }
     
     //creat getImage
     public Image getImages(String str)
     {
    	 Image image=null;
    	 try
    	 {
    		 image=Image.createImage(str);
    	 }
    	 catch(Exception e)
    	
    	 {
    		 e.printStackTrace();
         }
    	 return image;
     }
     //creat getPath
     public String getPath()
     {
    	 return img_path;
     }
     public void commandAction (Command c,Displayable d)
     {
    	 if(c==backCommand)
    	 {
    		 System.out.println("IamgeItems.backCommand");
    		// this.deleteAll();
    		 System.out.println(server);
    		 display.setCurrent(this.server);
    		 
    	 }
     }
	public void commandAction(Command c, Item i) {
		// TODO 自动生成方法存根
		System.out.println("ImageItem.CommandAction.item");
		if(c==command[0])
		{
			server.img_path="/7.PNG";
		}
		if(c==command[1])
		{
			server.img_path="/8.PNG";
		}
		
		if(c==command[2])
		{
			server.img_path="/9.PNG";
		}
		
		if(c==command[3])
		{
			server.img_path="/10.PNG";
		}
		
		if(c==command[4])
		{
			server.img_path="/11.PNG";
		}
		
		if(c==command[5])
		{
			server.img_path="/12.PNG";
		}
		
		//display.setCurrent(form);
		System.out.println("display.setCurrent(form)");
	}

}

⌨️ 快捷键说明

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