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

📄 infoscreen.java

📁 PDA餐饮管理系统,在掌上电脑实现的,可以开台,点菜等多功能模块
💻 JAVA
字号:
package junwei;

import java.util.Vector;

import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;

import rms.Menu;
import rms.RMSUtil;

import item.*;

/**
 * 信息显示界面
 */
public class InfoScreen extends Form 
implements CommandListener {
	private static InfoScreen instance;
    public static final int INFO_BREED=1;
    public static final int INFO_MENU=2;
    public static final int INFO_TASTE=3;
    public static final int INFO_BACKREASON=4;
    public static final int INFO_PAGE=5;
     
	private int tag;
	RecordEnumeration re;
	RecordStore rs;

	synchronized public static InfoScreen getInstance(int tag) {
		if (instance == null)
			instance = new InfoScreen();
		instance.tag=tag;
		instance.init();
		return instance;
	}

	private void init(){
		this.deleteAll();
		int width=this.getWidth();
		int height=this.getHeight()-20;
		switch (tag){
	
		case INFO_BREED:
			append(new ShowSyscodeItem("菜品类型",width,height,MainMidlet.RMS_BREED));
			break;
		case INFO_MENU:
			ShowMenuItem menuItem=new ShowMenuItem("菜品列表",width,height);
			 
			rs = RMSUtil.openRSAnymay(MainMidlet.RMS_MENU);
			if (rs != null) {
				try {
					re = rs.enumerateRecords(null, null, false);
					MainMidlet.menus.removeAllElements();
					while (re.hasNextElement()) {
						byte[] data = re.nextRecord();
						MainMidlet.menus.addElement(Menu.decode(data));
					}
					rs.closeRecordStore();
				} catch (Exception e) {
					System.out.println(e.toString());
				}
				System.out.println(MainMidlet.menus.size());
				sortMenus(MainMidlet.menus);
			}
			
			menuItem.setContent(MainMidlet.menus);
			append(menuItem);
			break;
		case INFO_TASTE:
			append(new ShowSyscodeItem("客人要求",width,height,MainMidlet.RMS_TASTE));
			break;
		case INFO_BACKREASON:
			append(new ShowSyscodeItem("退菜原因",width,height,MainMidlet.RMS_BACKREASON));
	
			break;
		case INFO_PAGE:
			append(new ShowSyscodeItem("菜品菜单",width,height,MainMidlet.RMS_PAGE));
			
			break;
		}
	}
	private InfoScreen() {
		super("信息浏览");
		addCommand(new Command("返回", Command.BACK, 1));
		setCommandListener(this);
	}

	public void commandAction(Command c, Displayable disp) {
		String cmd = c.getLabel();
		Navigator.flow(cmd);
	}
	public static void sortMenus(Vector menus){
		Menu menu_a,menu_b;
		for (int i=0;i<menus.size();i++)
			for (int j=i;j<menus.size();j++){
				menu_a=(Menu)(menus.elementAt(i));
				menu_b=(Menu)(menus.elementAt(j));
				if (Integer.parseInt(menu_a.getMenuId())>
				  Integer.parseInt(menu_b.getMenuId())){
					menus.setElementAt(menu_b,i);
					menus.setElementAt(menu_a,j);
				}
			}

}
	}

⌨️ 快捷键说明

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