📄 expenselist.java
字号:
/**
* @(#)ExpenseList.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 ExpenseList extends List implements CommandListener
{
/*显示类*/
private Display display = null;
/*足球彩票菜单类*/
public LotteryList lottery = null;
/*显示信息类*/
public LotteryInfoForm l_E_F;
/*错误类*/
private Alert errorAlert = null;
/*软键类*/
private Command backCommand = null;
private Command okCommand = null;
public Image[] icon = { createImage("/icon/phone.png"),createImage("/icon/football.png"),
createImage("/icon/english.png")};
public ExpenseList()
{
super("咨费菜单", List.IMPLICIT); //继承超类,并设置属性为当选择是当前操作的项目在命令初始化时被选中
append("竟猜费用", icon[0]);
append("信息费用", icon[1]);
append("咨询专家费用", icon[2]);
errorAlert = new Alert("ERROR", "连接网络失败 ", null, AlertType.ERROR);
errorAlert.setTimeout(1000);
this.backCommand = new Command("返回", Command.BACK, 2);
this.okCommand = new Command("确定", Command.OK, 2);
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 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 == okCommand)
{
int listIndex;
listIndex = this.getSelectedIndex(); //得到你所选择的是哪个菜单并作出响应, 你按下的是电话薄
if (listIndex == 0)
{
String info = getHtml(WebServerURL.getURL() + "football/football_lottery/lottery_expense.jsp");
if (!Language.isEnglish)
{
l_E_F = new LotteryInfoForm("竟猜费用", info, display, this);
}
else
{
l_E_F = new LotteryInfoForm("Lottery Expense", info, display, this);
}
DowloandGuage d = new DowloandGuage(); //连网的进度条
/*服务器出错时显示错误信息,主要实现思想是,运行服务器程序,如果有错误则输出error返回客户端*/
if (info.trim().compareTo("error") == 0)
{
this.display.setCurrent(errorAlert);
}
else
{
d.showForm(display, l_E_F); //当进度条好了以后,进入下个界面
}
}
if (listIndex == 1)
{
String info = getHtml(WebServerURL.getURL() + "football/football_lottery/info_expense.jsp");
if (!Language.isEnglish)
{
l_E_F = new LotteryInfoForm("信息费用", info, display, this);
}
else
{
l_E_F = new LotteryInfoForm("Info Expense", info, display, this);
}
DowloandGuage d = new DowloandGuage(); //连网的进度条
if (info.trim().trim().compareTo("error") == 0)
{
this.display.setCurrent(errorAlert);
}
else
{
d.showForm(display, l_E_F); //当进度条好了以后,进入下个界面
}
}
if (listIndex == 2)
{
String info = getHtml(WebServerURL.getURL() + "football/football_lottery/expert_expense.jsp");
if (!Language.isEnglish)
{
l_E_F = new LotteryInfoForm("咨询专家费用", info, display, this);
}
else
{
l_E_F = new LotteryInfoForm("Expert Expense", info, display, this);
}
DowloandGuage d = new DowloandGuage(); //连网的进度条
if (info.trim().trim().compareTo("error") == 0)
{
this.display.setCurrent(errorAlert); //显示错误
}
else
{
d.showForm(display, l_E_F); //当进度条好了以后,进入下个界面
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -