detailinfoform.java

来自「手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环」· Java 代码 · 共 156 行

JAVA
156
字号
/**
 * @(#)DetailInfoForm.java	
 * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
 * @version 	1.0, 10/05/2004
 * @author 	饶荣庆
 * @author 	
 */
package com.j2me.myphoto;

import com.j2me.main.*;	
import com.j2me.language.*;
import javax.microedition.lcdui.*;

/**
 *此类是用来详细列出朋友信息并维护朋友信息
 */
public class  DetailInfoForm extends Form implements CommandListener 
{
	private Display display = null;
	private PhotoBookMenu photoBookMenu = null;;   
	private PhotoList photoList = null;
	private BrowsePhoto browsePhoto = null;
	public DeletePhotoForm dff = null;
	public ModifyPhotoForm mff = null;
	public Command openCommand = null;
	public Command deleteCommand = null;			//定义确定软键
	public Command backCommand = null;			//定义离开软键
	public Command modifyCommand = null;			
	public StringItem idItem = null;
	public StringItem nameItem = null;
	public StringItem pathItem = null;
	private PhotoBook pb = null;
	private Photo photo = null;
	private String stringID;
	private int id;
	private int _id ;
	private	String _name;
	private	String _path;

	public DetailInfoForm(String s)
	{
		super(s);
		this.backCommand = new Command("返回", Command.BACK, 2);	
		this.openCommand = new Command("打开图片", Command.OK, 2);
		this.deleteCommand = new Command("删除", Command.BACK, 2);
		this.modifyCommand = new Command("修改", Command.BACK, 2);
		this.idItem = new StringItem("ID:", null);
		this.nameItem = new StringItem("姓名:",  null);
		this.pathItem = new StringItem("路径:",  null);
		this.addCommand(backCommand);
		this.addCommand(openCommand);
		this.addCommand(deleteCommand);
		this.addCommand(modifyCommand);
		this.setCommandListener(this);
	}

	public void showForm(Display display, PhotoList photoList, PhotoBookMenu photoBookMenu, BrowsePhoto browsePhoto, String idAnName)
	{
		this.display = display;
		this.photoBookMenu = photoBookMenu;
	   	this.photoList = photoList;
		this.browsePhoto = browsePhoto;

		this.pb = new PhotoBook();
		this.stringID = idAnName.substring(0, 3);   //分割字符串。使他可以获得的id增加到3位数
		this.id = Integer.parseInt(stringID);
		this.photo = pb.getPhoto(id);		 //用id来获得相片

		this._id = photo.getID();
		this._name = photo.getName();
		this._path = photo.getPath();

		this.idItem.setText(_id + ""); 
		this.nameItem.setText(_name);
		this.pathItem.setText("/myphoto/" + _path + ".png");
		this.append(idItem);
		this.append(nameItem);
		this.append(pathItem);
		this.display.setCurrent(this);
	}

	public void commandAction(Command c,Displayable s)
	{
		if(c == backCommand)
		{
			//if (browsePhoto.equals(null) == false)	  //判断显示哪个画面
			//{
				this.display.setCurrent(photoBookMenu);
			//}
			//else
			//{
				//this.display.setCurrent(photoBookMenu);
			//}
		}
		if (c == deleteCommand)
		{
			if (Language.isEnglish == true)  //修改语言为英文
			{				
				dff = new DeletePhotoForm("Delete Photo", _id, _name, _path); //修改相片信息
				dff.alert.setTitle("Prompt");
			    dff.alert.setString("Delete Succed!");
				dff.idItem.setLabel("Delete Photo");
				dff.showForm(display, photoBookMenu);
			}
			else
			{
				DeletePhotoForm dff = new DeletePhotoForm("删除", _id, _name, _path); //修改相片信息
				dff.alert.setTitle("提示");
			    dff.alert.setString("删除成功!");
				dff.idItem.setLabel("删除的相片名是:");
				dff.showForm(display, photoBookMenu);
			}
			
		}

		if (c == modifyCommand)
		{
			if (Language.isEnglish == true)  //修改语言为英文
			{				
                ModifyPhotoForm mff = new ModifyPhotoForm("Modify Photo");   //修改相片信息
				mff.alert.setTitle("Prompt");
			    mff.alert.setString("Modify Succed!");
				mff.infoAlert.setTitle("Prompt");
			    mff.infoAlert.setString("Id, Name, Path isn't null!");
			    mff.idItem.setLabel("ID:");
				mff.nameTextField.setLabel("Name:");
				mff.pathTextField.setLabel("Path:");
				mff.showForm(display, photoBookMenu, _id, _name, _path);
			}
			else
			{
				mff = new ModifyPhotoForm("Modify Photo");   //修改相片信息
			    mff.alert.setTitle("提示");
			    mff.alert.setString("修改成功!");
				mff.infoAlert.setTitle("提示");
			    mff.infoAlert.setString("Id, 图片名, 路径不能为空!");
				mff.idItem.setLabel("ID:");
				mff.nameTextField.setLabel("名字:");
				mff.pathTextField.setLabel("路径:");
				mff.showForm(display, photoBookMenu, _id, _name, _path);
			}				
		}

		
		if (c == openCommand)
		{
			PhotoCanvas photoCanvas = new PhotoCanvas(_path);  //用图片路径创建一个对象
			photoCanvas.showForm(display, photoBookMenu);
		}
	}
}
	
		


⌨️ 快捷键说明

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