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

📄 resultlist.java

📁 手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环境是:jsdk1.4以上
💻 JAVA
字号:
/**
 * @(#)ResultList.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.*;

/**
 *此类是足球彩票投注的主菜单类
 */
public class ResultList extends List implements CommandListener
{
	/*显示类*/
	private Display display = null;

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

	/*足球彩票开奖信息窗体类*/
	private LotteryInfoForm L_I_F = null;

	/*查询中奖没有类*/
	private PersonForm p_F;

	/*错误类*/
	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[2];

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

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

	public ResultList()
	{
		super("查看", List.IMPLICIT);    //继承超类,并设置属性为当选择是当前操作的项目在命令初始化时被选中
		append("开奖结果", icon[0]);
		append("中奖没有", icon[1]);
		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", "先生或女士们!请注意!如果您确定查看。这将花掉您5毛钱!", null, AlertType.WARNING);
		alarmAlert.addCommand(goCommand);
		alarmAlert.addCommand(noCommand);
		alarmAlert.setCommandListener(this);
		this.initData(LotteryServerURL.getURL() + "/lottery_result.jsp");		
		this.addCommand(backCommand);
		this.addCommand(okCommand);
		this.setCommandListener(this);
	}

	/*
	 *显示菜单界面方法
	 */
	public void showForm(Display display, LotteryList lottery)	//用来显示界面
	{		
		this.display = display;
	   	this.lottery = lottery;
		this.display.setCurrent(this);
	}

	
	/*处理网络资源*/
	private void initData(String URLString)
	{
		String html = this.getHtml(URLString);
		
		//看网络是不是有错误
		this.error = html;
		//处理字符串
		this.data = DisposeData.getStringGroup(html, "~", 2);
	}
    
	/**
	 *定义创建菜单图片
     */
	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;
	}

	/**
	 *实现监视器方法,监听用户动作
	 */
	public void commandAction(Command c, Displayable s)
	{
		if(c == backCommand)
		{
			this.display.setCurrent(lottery);
		}
		if (c == noCommand)
		{
			this.display.setCurrent(this);
		}
		if (c == okCommand)
		{
			if (this.getSelectedIndex() == 0)
			{
				this.display.setCurrent(alarmAlert);
			}
			else
			{
				if (Language.isEnglish)
				{
					p_F = new PersonForm("Person");
					p_F.showForm(display, this);
				}
				else
				{
					p_F = new PersonForm("中奖吗?");
					p_F.showForm(display, this);
				}

			}			
		}

		if (c == goCommand)
		{
			L_I_F = new LotteryInfoForm(this.getString(this.getSelectedIndex()) + " " + data[0], "开奖结果如下:\n" + data[1] + "\n尊敬的客户您中奖没啊!", display, this);
												
			/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
			if (error.trim().compareTo("error") == 0)
			{
				this.display.setCurrent(errorAlert);
			}
			else
			{
				L_I_F.showForm(); //this.display.setCurrent(L_I_F);
			}
		}
	}
}

⌨️ 快捷键说明

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