📄 phonebookmenu.java
字号:
/**
* @(#)PhoneBookMenu.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.*;
/**
*类PhoneBookMenu是用来描述电话薄功能菜单界面。
*/
public class PhoneBookMenu extends List implements CommandListener
{
private Display display = null;
private MainList mainList = null;
public AddFriendForm addFriendForm = null;
public FriendList friendList = null;
public SearchForm searchForm = null;
public Alert form = null;
public Command okCommand = null; //定义确定软键
public Command backCommand = null; //定义离开软键
//public Ticker ticker = new Ticker("欢迎来到动感在线!请选择要的功能.");
public Image[] icon = { createImage("/icon/english.png"),createImage("/icon/football.png"),
createImage("/icon/music.png"), createImage("/icon/dictionary.png"),
createImage("/icon/shooping.png")};
public String [] stringMenu = {"添加", "列出所有朋友通过姓名" , "列出所有朋友通过ID" , "用名搜索", "用ID搜索"};
public PhoneBookMenu(String s) //初始话功能菜单
{
super(s, List.IMPLICIT); //继承超类,并设置属性为当选择是当前操作的项目在命令初始化时被选中
this.okCommand = new Command("确定", Command.OK, 2);
this.backCommand = new Command("返回", Command.EXIT, 2);
this.addCommand(okCommand);
this.addCommand(backCommand);
this.append(stringMenu[0], icon[0]);
this.append(stringMenu[1], icon[1]);
this.append(stringMenu[2], icon[2]);
this.append(stringMenu[3], icon[3]);
this.append(stringMenu[4], icon[4]);
this.setCommandListener(this);
//this.setTicker(ticker);
}
public void showForm(Display display, MainList mainList) //用来显示界面
{
this.display = display;
this.mainList = mainList;
this.display.setCurrent(this);
}
private Image createImage(String name) //定义创建菜单图片
{
Image aImage =null;
try
{
aImage = Image.createImage(name);
}
catch(Exception e)
{
System.out.println("不能找到图标.");
}
return aImage;
}
public void commandAction(Command c,Displayable s)
{
if(c == backCommand)
{
this.display.setCurrent(mainList);
}
else
{
int listIndex;
listIndex = this.getSelectedIndex(); //得到你所选择的是哪个菜单并作出响应
if (listIndex == 0) //对用户选择的功能进行判断并作出响应。 添加功能
{
if (Language.isEnglish == true) //修改语言为英文
{
this.addFriendForm = new AddFriendForm("Add Friend");
this.addFriendForm.addAlert.setTitle("Prompt");
this.addFriendForm.addAlert.setString("Add Succed!");
this.addFriendForm.modifyAlert.setTitle("Prompt");
this.addFriendForm.modifyAlert.setString("This Record is exist! Make Sure Modify!");
this.addFriendForm.infoAlert.setTitle("Prompt");
this.addFriendForm.infoAlert.setString("Id, Name, Phone isn't null!");
this.addFriendForm.idTextField.setLabel("Enter ID");
this.addFriendForm.nameTextField.setLabel("Enter Name");
this.addFriendForm.phoneTextField.setLabel("Enter Phone");
this.addFriendForm.eMailTextField.setLabel("Enter Email");
//this.addFriendForm.showForm(display, phoneBookMenu);
}
else
{
this.addFriendForm = new AddFriendForm("添加");
this.addFriendForm.addAlert.setTitle("提示");
this.addFriendForm.addAlert.setString("添加成功!");
this.addFriendForm.modifyAlert.setTitle("提示");
this.addFriendForm.modifyAlert.setString("这条记录已经存在!是否对它进行修改!");
this.addFriendForm.infoAlert.setTitle("提示");
this.addFriendForm.infoAlert.setString("Id, 姓名, 电话不能为空!");
this.addFriendForm.idTextField.setLabel("输入ID");
this.addFriendForm.nameTextField.setLabel("输入名");
this.addFriendForm.phoneTextField.setLabel("输入电话");
this.addFriendForm.eMailTextField.setLabel("输入邮箱");
}
addFriendForm.showForm(display, this);
}
if (listIndex == 1) //用户列表
{
if (Language.isEnglish ==true )
{
this.friendList = new FriendList("Friend Info List", 0);
}
else
{
this.friendList = new FriendList("朋友信息列表", 0);
}
this.friendList.showForm(display, this);
}
if (listIndex == 2)
{
if (Language.isEnglish == true )
{
this.friendList = new FriendList("Friend Info List", 1);
}
else
{
this.friendList = new FriendList("朋友信息列表", 1);
}
this.friendList.showForm(display, this);
}
if (listIndex == 3)
{
if (Language.isEnglish == true )
{
this.searchForm = new SearchForm("Search Friend");
this.searchForm.searchTextField.setLabel("Enter Name:");
this.searchForm.errorAlert.setTitle("Error");
this.searchForm.errorAlert.setString("Not Find!");
this.searchForm.showForm(display, this, 1);
}
else
{
this.searchForm = new SearchForm("搜索朋友");
this.searchForm.searchTextField.setLabel("输入名:");
this.searchForm.errorAlert.setTitle("错误");
this.searchForm.errorAlert.setString("没有找到你要的记录!");
this.searchForm.showForm(display, this, 1);
}
}
if (listIndex == 4)
{
if (Language.isEnglish == true )
{
this.searchForm = new SearchForm("Search Friend");
this.searchForm.searchTextField.setLabel("Enter ID:");
this.searchForm.errorAlert.setTitle("Error");
this.searchForm.errorAlert.setString("Not Find!");
this.searchForm.showForm(display, this, 2);
}
else
{
this.searchForm = new SearchForm("搜索朋友");
this.searchForm.searchTextField.setLabel("输入 ID:");
this.searchForm.errorAlert.setTitle("错误");
this.searchForm.errorAlert.setString("没有找到你要的记录!");
this.searchForm.showForm(display, this, 2);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -