日期:2014-05-20  浏览次数:20778 次

请教:连接远程服务器时,如何显示另外一个等待Form?
连接服务器线程类:
public   class   LoginThread   implements   Runnable{
  String   loginURL=   "http://localhost/.../... "
  String   username= " ";
  String   password= " ";
  public   SeClientLoginThread(String   username,String   password){
                this.username=username;
                this.password=password;
        }

  public   void   run(){
                DataInputStream   ds=null;
                HttpConnection   hc=null;
                DataOutputStream   dos=null;
                DataInputStream   dis=null;
                try{
     //我是在这再加一个等待Form的装载代码:
     //   ConnectServerMidlet   connect=new   ConnectServerMidlet();
                  //display.setCurrent(connect.get_form());//显示等待画面
                //这样添加后当用户点击LoginMidlet后出现等待画面后程序就死掉了
                    hc   =   (HttpConnection)Connector.open(loginURL);
                        //设置请求属性
                        hc.setRequestMethod(HttpConnection.POST);
                  //下面是一堆有关跟服务器取得连接后的验证信息等
                  //....

              }
                  catch   (IOException   ex)   {
                ex.printStackTrace();
                }
}

}

等待画面:

public   class   ConnectServerMidlet   {

        private   Image   image;

        private   Form   connect;

        private   ImageItem   imageItem;
        public   Image   get_image()   {
                if   (image==   null)   {
                        //   Insert   pre-init   code   here
                        try   {
                                image=Image.createImage( "/com/swc/se/SeClient/Logic/waitscreen.png ");
                        }   catch   (java.io.IOException   exception)   {
                                exception.printStackTrace();
                        }
                        //   Insert   post-init   code   here