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

📄 menu.java

📁 用自己写的j2me rms引擎写的电话本 功能是: 1.添加 2.查询 3.列出所有的资料 1.修改 2.删除 3.排序
💻 JAVA
字号:
/**
 * @(#)PhoneBookMenu.java	
 * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
 * @version 	1.0, 10/05/2004
 * @author 	饶荣庆
 * @author 	
 */
package org.wuhua.photobook;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;

import org.wuhua.fuck.core.ResultSet;
import org.wuhua.fuck.core.SQLException;
import org.wuhua.photobook.service.Service;

/**
 *类PhoneBookMenu是用来描述电话薄功能菜单界面。
 */
public class  Menu extends List implements CommandListener 
{
	private Display display = null;

	private FriendList friendList = new FriendList("电话本列表");
	private FindFriendForm find = new FindFriendForm("查找电话本");
	public Alert form = null;
	public Command okCommand = null;			//定义确定软键
	public Command backCommand = null;			//定义离开软键
	//public Ticker ticker = new Ticker("欢迎来到动感在线!请选择要的功能.");
 
	private AddFriendForm addform = new AddFriendForm("添加");
	public  String [] stringMenu = {"添加", "电话列表" , "搜索"};
    
	public	Menu(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], null);
		this.append(stringMenu[1], null);
		this.append(stringMenu[2], null);
 
		this.setCommandListener(this);
	    //this.setTicker(ticker);
	}

    public void show(Display display)	//用来显示界面
	{
		this.display = display;
	   
		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(this.getSelectedIndex() == 0){
			addform.showForm(display, this);
		}else if(this.getSelectedIndex() == 1){
			listAllFriend();
		}else{
			this.find.showForm(display, this);
		}
		 
	}

	private void listAllFriend() {
		ResultSet rs = Service.getInstance().find("select : friend");
		try {
			while(rs.next()){
				friendList.append(rs.getString("f_name"), null);
				
			}
		} catch (SQLException e) {
		 
			e.printStackTrace();
		}
		friendList.showForm(display, this);
	}
}

⌨️ 快捷键说明

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