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

📄 foreshowlist.java

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

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

/*
 *此类是用来读取数据库球队中赛程的球队名,并把所有球队的赛程都列在一个球队表上以供用户浏览
 */
public class ForeshowList extends List implements CommandListener
{
	/*显示类*/
	private Display display = null;

	/*用于切换的界面类*/
	public Foreshow foreshow = null;

	/*球队赛程详细信息*/
	public DetailForeshowInfoForm detail = null;

	//连网络错误
	private Alert errorAlert = null;

	private Command backCommand = null;
	private Command okCommand = null;

	public ForeshowList(String title, Display display, Foreshow foreshow)
	{
		super(title, List.IMPLICIT);
		//获得用户切换界面
		this.display = display;
	   	this.foreshow = foreshow;
		this.initList();
		errorAlert  = new Alert("ERROR", "连接网络失败 ", null, AlertType.ERROR);
	    errorAlert.setTimeout(1000);
		this.okCommand = new Command("详细信息", Command.OK, 2);
		this.backCommand = new Command("返回", Command.BACK, 2);
		this.addCommand(backCommand);
		this.addCommand(okCommand);
		this.setCommandListener(this);
	}

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

	/*
	 *初始化一些球队信息
	 */
	private void initList()
	{
		String html = "";
		/* Thread t = new Thread() 
		{   				 				 
			public void run() 
			{ */
			try
			{	
				//String parameter = "name=" + nameText.getString() + "&password=" + passwordText.getString();
				
				//获得服务器用户保存的内容
			    html = ConnectHttp.invokeJSP(WebServerURL.getURL() + "football/england_foreshow.jsp");
				
				//处理HTML标记语言
				html = DisposeHTML.getBody(html);	
				html = Unicode.unicodeToString(html);
			}
			catch(IOException e)
			{
			    this.display.setCurrent(errorAlert);
				System.out.println(e);
			}
		/* }						
		};
	   t.start();*/	  //启动线程让它进行连网	
	   
	   String bufferstr = html.trim();	
	   bufferstr = Unicode.unicodeToString(bufferstr); //处理中文问题
	   int j = 0;
	   while(true)	  //处理从网络上获得的数据并对其进行处理
	   {
		   j = bufferstr.indexOf("~");
		   if (j == -1)
		   {
			   break;
		   }
		   this.append(bufferstr.substring(0, j), null);
		   bufferstr = bufferstr.substring(j + 1, bufferstr.length());
	   }

	}




	public void commandAction(Command c, Displayable s)
	{
		if(c == backCommand)
		{
			this.display.setCurrent(foreshow);
		}
	   
		if (c == okCommand)
		{
			String html = "";
			Image image = null;

			String str = this.getString(this.getSelectedIndex()).trim(); //获得球队名字,去掉空格
			int j;
			j = str.indexOf("-");

			String name = str.substring(0, j-1);
			str = str.substring(j+2, str.length());

			int i = str.indexOf("-");
			String degree = str.substring(0, i);
			String court = str.substring(i+2, str.length()).trim();
			

			/* Thread t = new Thread() 
		    {   				 				 
			public void run() 
			{ */
			try
			{	
				//从列表中获取球队名字用于查询
				String parameter = "name=" + name + "&degree=" + degree;
				//System.out.println(parameter);
				//System.out.println(court +"fdsfsd");
				
				//获得服务器用户保存的内容
			    html = ConnectHttp.invokeJSP(WebServerURL.getURL() + "football/england_foreshow_info.jsp", parameter);

				/*这里有一个很大很大的问题。为什么这里面有中文路径就不行*/
				//从网络上获取图象资源
				image = ConnectHttp.getJspImage(WebServerURL.getURL() + "football/image/" + court +".png");
				
				//处理HTML标记语言
				html = DisposeHTML.getBody(html);	
				
				//把Unicode转换为中文
				html = Unicode.unicodeToString(html);	   
			}
			catch(IOException e)
			{
				System.out.println(e);
			}
			catch(NullPointerException e)
		    {
				System.out.println(e);
		    }
			catch(IllegalArgumentException e)
		    {
				System.out.println(e);
			}
			/* }						
		    };
		    t.start();*/	  //启动线程让它进行连网	
			//System.out.println(html);
			DowloandGuage d = new DowloandGuage();	//连网的进度条
			//创建球队详细列表的对象
			detail = new DetailForeshowInfoForm("赛程详细信息", image, html, display, this, null);
			d.showForm(display, detail);

		}
	}
}

⌨️ 快捷键说明

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