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

📄 detailinfoform.java

📁 手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环境是:jsdk1.4以上
💻 JAVA
字号:
/**
 * @(#)DetailInfoForm.java	
 * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
 * @version 	1.0, 10/05/2004
 * @author 	饶荣庆
 * @author 	
 */
package com.j2me.phonebook;

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

/**
 *此类是用来详细列出朋友信息并维护朋友信息
 */
public class  DetailInfoForm extends Form implements CommandListener 
{
	private Display display = null;
	private PhoneBookMenu phoneBookMenu = null;
	public DeleteFriend dff = null;
	public ModifyFriend mff = null;
	public Command deleteCommand = null;			//定义确定软键
	public Command backCommand = null;			//定义离开软键
	public Command modifyCommand = null;			
	public StringItem idItem = null;
	public StringItem nameItem = null;
	public StringItem phoneItem = null;
	public StringItem eMailItem = null;
	private PhoneBook pb = null;
	private Friend friend = null;
	private String stringID;
	private int id;
	private int _id ;
	private	String _name;
	private	String _phone;
	private	String _eMail;

	public DetailInfoForm(String s)
	{
		super(s);
		this.backCommand = new Command("返回", Command.BACK, 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.phoneItem = new StringItem("电话:",  null);
		this.eMailItem = new StringItem("邮箱:",  null);
		this.addCommand(backCommand);
		this.addCommand(deleteCommand);
		this.addCommand(modifyCommand);
		this.setCommandListener(this);
	}

	public void showForm(Display display, PhoneBookMenu phoneBookMenu, String idAnName)
	{
		this.display = display;
	   	this.phoneBookMenu = phoneBookMenu;

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

		this._id = friend.getID();
		this._name = friend.getName();
		this._phone = friend.getPhone();
		this._eMail = friend.getEmail();

		this.idItem.setText(_id + ""); 
		this.nameItem.setText(_name);
		this.phoneItem.setText(_phone);
		this.eMailItem.setText(_eMail);
		this.append(idItem);
		this.append(nameItem);
		this.append(phoneItem);
		this.append(eMailItem);
		this.display.setCurrent(this);
	}

	public void commandAction(Command c,Displayable s)
	{
		if(c == backCommand)
		{
			this.display.setCurrent(phoneBookMenu);
		}
		if (c == deleteCommand)
		{
			if (Language.isEnglish == true)  //修改语言为英文
			{				
				dff = new DeleteFriend("Delete Friend", _id, _name, _phone, _eMail); //删除朋友信息
				dff.alert.setTitle("Prompt");
			    dff.alert.setString("Delete Succed!");
				dff.idItem.setLabel("Delete Friend");
				dff.showForm(display, phoneBookMenu);
			}
			else
			{
				DeleteFriend dff = new DeleteFriend("删除", _id, _name, _phone, _eMail); //删除朋友信息
				dff.alert.setTitle("提示");
			    dff.alert.setString("删除成功!");
				dff.idItem.setLabel("删除的姓名是:");
				dff.showForm(display, phoneBookMenu);
			}
			
		}

		if (c == modifyCommand)
		{
			if (Language.isEnglish == true)  //修改语言为英文
			{				
                ModifyFriend mff = new ModifyFriend("Modify Friend");   //修改朋友信息
				mff.alert.setTitle("Prompt");
			    mff.alert.setString("Modify Succed!");
				mff.infoAlert.setTitle("Prompt");
			    mff.infoAlert.setString("Id, Name, Phone isn't null!");
			    mff.idItem.setLabel("ID:");
				mff.nameTextField.setLabel("Name:");
				mff.phoneTextField.setLabel("Phone:");
				mff.eMailTextField.setLabel("Email:");
				mff.showForm(display, phoneBookMenu, _id, _name, _phone, _eMail);
			}
			else
			{
				mff = new ModifyFriend("Modify Friend");   //修改朋友信息
			    mff.alert.setTitle("提示");
			    mff.alert.setString("修改成功!");
				mff.infoAlert.setTitle("提示");
			    mff.infoAlert.setString("Id, 姓名, 电话不能为空!");
				mff.idItem.setLabel("ID:");
				mff.nameTextField.setLabel("姓名:");
				mff.phoneTextField.setLabel("电话:");
				mff.eMailTextField.setLabel("邮箱:");
				mff.showForm(display, phoneBookMenu, _id, _name, _phone, _eMail);
			}	
			
		}
	}
}
		


⌨️ 快捷键说明

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