📄 searchtermform.java
字号:
/**
* @(#)SearchTermForm.java
* 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.main.*;
import com.j2me.language.*;
import com.j2me.common.*;
import java.io.*;
import javax.microedition.lcdui.*;
/**
*此类为搜索球队的类
*/
public class SearchTermForm extends Form implements CommandListener
{
private Display display = null;
private TeamMenuList team = null;
public DetailTeamInfoForm detail;
public static Alert errorAlert = null; //找不到记录是显示错误信息
public static TextField searchTextField= null;
public Command okCommand = null; //定义确定软键
public Command backCommand = null; //
public SearchTermForm(String s)
{
super(s);
this.errorAlert = new Alert("错误", "找不到这个球队的详细信息", null, AlertType.ERROR); //初始化信息
this.errorAlert.setTimeout(1000);
this.searchTextField = new TextField(null, null, 30, TextField.ANY);
this.append(searchTextField);
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 team)
{
this.display = display;
this.team = team;
this.display.setCurrent(this);
}
public void commandAction(Command c,Displayable s)
{
if(c == backCommand)
{
this.display.setCurrent(team);
}
if (c == okCommand)
{
String html = "";
Image image = null;
String isOk = ""; //判断找到没有
String str = searchTextField.getString().trim(); //获得要搜索的球队名
int i = 0;//用于获得图片的绝对路径
/* Thread t = new Thread()
{
public void run()
{ */
try
{
//从列表中获取球队名字用于查询
String parameter = "name=" + str;
System.out.println(parameter);
//获得服务器用户保存的内容
html = ConnectHttp.invokeJSP(WebServerURL.getURL() + "football/england_team_info.jsp", parameter);
//处理HTML标记语言
html = DisposeHTML.getBody(html);
//System.out.println("dfsdfsd"+html);
//把Unicode转换为中文
html = Unicode.unicodeToString(html);
isOk = html;
}
catch(IOException e)
{
this.display.setCurrent(errorAlert);
System.out.println(e);
}
try
{
/*------------------------------------------------------
*获得图片路径
*/
String s1 = html.trim();
int j;
j = s1.indexOf("~");
i = Integer.parseInt(s1.substring(0, j));
/*-----------------------------------------------------------------*/
}
catch(StringIndexOutOfBoundsException e)
{
isOk = "false";
System.out.println(e);
}
try
{
//从网络上获取图象资源
image = ConnectHttp.getJspImage(WebServerURL.getURL() + "football/image/" + i +".png");
}
catch(IOException e)
{
System.out.println(e);
}
catch(NullPointerException e)
{
System.out.println(e);
}
catch(IllegalArgumentException e)
{
System.out.println(e);
}
/* }
};
t.start();*/ //启动线程让它进行连网
if (isOk.trim().compareTo("false") == 0 || searchTextField.getString() == null)
{
this.display.setCurrent(errorAlert);
}
else
{
DowloandGuage d = new DowloandGuage(); //连网的进度条
//创建球队详细列表的对象
if (Language.isEnglish)
{
detail = new DetailTeamInfoForm("Team Info", image, html, display, null, this);
}
else
{
detail = new DetailTeamInfoForm("球队详细信息", image, html, display, null, this);
}
d.showForm(display, detail);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -