modifyphotoform.java

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

JAVA
101
字号
/**
 * @(#)ModifyPhotoForm.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 javax.microedition.lcdui.*;

/**
 *此类是修改朋友信息的类
 */
public class  ModifyPhotoForm extends Form implements CommandListener 
{
	private Display display = null;
	private PhotoBookMenu photoBookMenu = null;
	public static Alert infoAlert = new Alert(null, null, null, AlertType.INFO); 	 //动态的改变语言
	public Alert alert = null;
	public StringItem idItem = null;
	public TextField nameTextField= null;
	public TextField pathTextField= null;
	public Command okCommand = null;			//定义确定软键
	public Command backCommand = null;			//定义离开软键
	private boolean isModify = true;   //确定可以修改
	private int _id;

	public ModifyPhotoForm(String s)
	{
		super(s);
		this.alert = new Alert("提示", "修改成功", null, AlertType.INFO);	 //初始化信息
		this.alert.setTimeout(1000);
		this.infoAlert.setTimeout(1000);
		this.okCommand = new Command("确定", Command.OK, 2);	
		this.backCommand = new Command("返回", Command.BACK, 2);
		this.idItem = new StringItem("ID是",  null);
		this.nameTextField = new TextField("输入名", null, 30, TextField.ANY);
		this.pathTextField = new TextField("输入路径", null, 15, TextField.ANY);
		this.append(idItem);
		this.append(nameTextField);
		this.append(pathTextField);
		this.addCommand(backCommand);
		this.addCommand(okCommand);
		this.setCommandListener(this);
	}

	
	public void showForm(Display display, PhotoBookMenu photoBookMenu, int id, String name, String path)
	{
		this.idItem.setText(id + "");
		this.nameTextField.setString(name);
		this.pathTextField.setString( path);
		this.display = display;
	   	this.photoBookMenu = photoBookMenu;
		this.display.setCurrent(this);
	}

	public void commandAction(Command c,Displayable s)
	{
		if(c == backCommand)
		{
			this.display.setCurrent(photoBookMenu);
		}

		if (c == okCommand)			//修改
		{
			PhotoBook pb = new PhotoBook();
			try
			{
				_id = Integer.parseInt(idItem.getText());
			}
			catch(NumberFormatException e)
			{
				this.display.setCurrent(infoAlert);
				isModify = false;
			}
			String _name = nameTextField.getString();
		    String _path = pathTextField.getString();
			if (_name.compareTo("") == 0)
			{
				this.display.setCurrent(infoAlert);
				isModify = false;
			}
			if (_path.compareTo("") == 0)
			{
				this.display.setCurrent(infoAlert);
				isModify = false;
			}
			if (isModify == true)  //确定修改
			{
				pb.modifyPhoto(_id, _name, _path);  //调用修改方法	
				this.display.setCurrent(alert, photoBookMenu);
				pb.closeRS();
			}
			isModify =true;			
		}
	}
}

⌨️ 快捷键说明

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