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

📄 expertlist.java

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

import com.j2me.football.*;
import com.j2me.language.*;
import com.j2me.common.*;
import java.io.*;
import javax.microedition.lcdui.*;


/**
 *类ExpertList是用来描述专家建议类。
 */
public class  ExpertList extends List implements CommandListener
{
	
	/*显示类*/
	private Display display = null;

	/*足球彩票菜单类*/
	public LotteryList lottery = null;

	/*专家建议信息窗体类*/
	private LotteryInfoForm L_I_F = null;

	/*错误类*/
	private Alert errorAlert = null;

	/*警告类*/
	private Alert alarmAlert = null;


	/*软键类*/
	private Command backCommand = null;
	private Command okCommand = null;
	private Command goCommand = null;
	private Command noCommand = null;

	/*定义字符串,用于获得网络资源,并处理字符串,使它合乎要求*/
	public String[] data = new String[6];

	/*初始化有错误*/
	private String error = "error";

	public Image[] icon = { createImage("/icon/phone.png"),createImage("/icon/football.png"), 
		                    createImage("/icon/music.png"),  createImage("/icon/dictionary.png"), 
							createImage("/icon/myphoto.png")};


    
	public	ExpertList()		  //初始话功能菜单
	{
		super(null, List.IMPLICIT);    //继承超类,并设置属性为当选择是当前操作的项目在命令初始化时被选中
		append("专家建议一", icon[0]);
		append("专家建议二", icon[1]);
		append("专家建议三", icon[2]);
		append("专家建议四", icon[3]);
		append("专家建议五", icon[4]);
		this.backCommand = new Command("返回", Command.BACK, 2);
		this.okCommand = new Command("确定", Command.OK, 2);
		this.goCommand = new Command("OK", Command.OK, 2);
		this.noCommand = new Command("back", Command.BACK, 2);
		errorAlert  = new Alert("ERROR", "连接网络失败", null, AlertType.ERROR);
		errorAlert.setTimeout(1000);
		alarmAlert  = new Alert("WARNING", "先生或女士们!请注意!如果您确定查看。这将花掉您1块钱!", null, AlertType.WARNING);
		alarmAlert.addCommand(goCommand);
		alarmAlert.addCommand(noCommand);
		alarmAlert.setCommandListener(this);
		this.initData(LotteryServerURL.getURL() + "/football_lottery_expert_suggest.jsp");		
		this.addCommand(backCommand);
		this.addCommand(okCommand);
		this.setCommandListener(this);
	}

	/*处理网络资源*/
	private void initData(String URLString)
	{
		String html = this.getHtml(URLString);
		
		//看网络是不是有错误
		this.error = html;
		//处理字符串
		this.data = DisposeData.getStringGroup(html, "~", 6);
	}


	/*
	 *显示菜单界面方法
	 */
	public void showForm(Display display, LotteryList lottery)	//用来显示界面
	{		
		this.display = display;
	   	this.lottery = lottery;
		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;
     }

	 /**
	 *初始化
	 */
	private String getHtml(String URLString)
	{
		String html = "";
		/* Thread t = new Thread() 
		{   				 				 
			public void run() 
			{ */
			try
			{	
				
				//获得服务器用户保存的内容
			    html = ConnectHttp.invokeJSP(URLString);
				
				//处理HTML标记语言
				html = DisposeHTML.getBody(html);	
			}
			catch(IOException e)
			{
			    this.display.setCurrent(errorAlert);
				System.out.println(e);
			}
		/* }						
		};
	   t.start();*/	  //启动线程让它进行连网	
	   
	   html = html.trim();	
	   return html;
	}


    /*查看专家建议方法*/
	private void lookSuggest()
	{
		    int listIndex;
			listIndex = this.getSelectedIndex();	 //得到你所选择的是哪个菜单并作出响应, 你按下的是电话薄
			switch(listIndex)
			{
				case 0:
				{
					L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()), data[1], display, this);
												
					/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
					if (error.trim().compareTo("error") == 0)
					{
						this.display.setCurrent(errorAlert);
					}
					else
					{
						L_I_F.showForm(); //this.display.setCurrent(L_I_F);
					} break;
				}

				case 1:
				{
					L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()), data[2], display, this);
												
					/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
					if (error.trim().compareTo("error") == 0)
					{
						this.display.setCurrent(errorAlert);
					}
					else
					{
						L_I_F.showForm(); //this.display.setCurrent(L_I_F);
					} break;
				}

				case 2:
				{
					L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()), data[3], display, this);
												
					/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
					if (error.trim().compareTo("error") == 0)
					{
						this.display.setCurrent(errorAlert);
					}
					else
					{
						L_I_F.showForm(); //this.display.setCurrent(L_I_F);
					} break;
				}
				
				case 3:
				{
					L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()), data[4], display, this);
												
					/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
					if (error.trim().compareTo("error") == 0)
					{
						this.display.setCurrent(errorAlert);
					}
					else
					{
						L_I_F.showForm(); //this.display.setCurrent(L_I_F);
					} break;
				}

				case 4:
				{
					L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()), data[5], display, this);
												
					/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
					if (error.trim().compareTo("error") == 0)
					{
						this.display.setCurrent(errorAlert);
					}
					else
					{
						L_I_F.showForm(); //this.display.setCurrent(L_I_F);
					} break;
				}
			}
	}


	/**
	 *实现监视器方法,监听用户动作
	 */
	public void commandAction(Command c, Displayable s)
	{
		if(c == backCommand)
		{
			this.display.setCurrent(lottery);
		}
		if (c == okCommand)
		{
			this.display.setCurrent(alarmAlert);
		}
		if (c == noCommand)
		{
			this.display.setCurrent(this);
		}
		if (c == goCommand)
		{
			/*执行查看*/
			this.lookSuggest();
		}
	}

}


		
	

	

⌨️ 快捷键说明

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