📄 personform.java
字号:
/*
* @(#)PersonForm.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 PersonForm extends Form implements CommandListener
{
private Display display;
/*表示层类*/
private Displayable dsa;
private LotteryInfoForm l_I_F;
/*错误*/
private Alert errorAlert = null;
/*数据输入对象*/
public TextField userID; //输入用户ID;
public TextField point; //由用户输入期数
//定义离开软键
public Command backCommand = null;
public Command okCommand = null;
public PersonForm(String title)
{
super(title);
this.point = new TextField("*请输入期数", "", 30, TextField.NUMERIC);
this.userID = new TextField("*输入用户ID:", "", 30, TextField.ANY);
this.backCommand = new Command("返回", Command.BACK, 2);
this.okCommand = new Command("确定", Command.BACK, 2);
this.addCommand(backCommand);
this.addCommand(okCommand);
this.append(userID);
this.append(point);
this.setCommandListener(this);
}
/**
*显示菜单界面方法
*/
public void showForm(Display display, Displayable dsa) //用来显示界面
{
this.display = display;
this.dsa = dsa;
this.display.setCurrent(this);
}
/**
*定义私有方法下载数据
*/
private String getHtml(String URLString, String parameter)
{
String html = "";
/* Thread t = new Thread()
{
public void run()
{ */
try
{
//获得服务器用户保存的内容
html = ConnectHttp.invokeJSP(URLString, parameter);
//处理HTML标记语言
html = DisposeHTML.getBody(html);
}
catch(IOException e)
{
this.display.setCurrent(errorAlert);
System.out.println(e);
}
/* }
};
t.start();*/ //启动线程让它进行连网
return html;
}
public void commandAction(Command c,Displayable s)
{
if(c == backCommand)
{
this.display.setCurrent(dsa);
}
if (c == okCommand)
{
if (userID.getString().trim().compareTo("") != 0 && point.getString().trim().compareTo("") != 0)
{
//参数
String parameter = "userID=" + userID.getString().trim() + "&point=" + point.getString().trim();
if (Language.isEnglish)
{
if (this.getHtml(LotteryServerURL.getURL() + "/lottery_person.jsp", parameter).trim().compareTo("false") != 0)
{
l_I_F = new LotteryInfoForm("Result", this.getHtml(LotteryServerURL.getURL() + "/lottery_person.jsp", parameter), display, this );
l_I_F.showForm();
}
else
{
errorAlert = new Alert("ERROR", "对不起!连接网络错误", null, AlertType.ERROR);
errorAlert.setTimeout(2000);
this.display.setCurrent(errorAlert);
}
}
else
{
if (this.getHtml(LotteryServerURL.getURL() + "/lottery_person.jsp", parameter).trim().compareTo("false") != 0)
{
l_I_F = new LotteryInfoForm("中奖没有", this.getHtml(LotteryServerURL.getURL() + "/lottery_person.jsp", parameter), display, this );
l_I_F.showForm();
}
else
{
errorAlert = new Alert("ERROR", "对不起!连接网络错误", null, AlertType.ERROR);
errorAlert.setTimeout(2000);
this.display.setCurrent(errorAlert);
}
}
}
else
{
errorAlert = new Alert("ERROR", "先生请添完整您的数据。谢谢!", null, AlertType.ERROR);
errorAlert.setTimeout(2000);
this.display.setCurrent(errorAlert);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -