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

📄 tablelist.java

📁 联网斗地主 java版本 用jbuilder2005编写
💻 JAVA
字号:
package poker;

import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Command;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class TableList implements CommandListener{
  Timer one;
  MyTask oneTask;
  String[] imID=new String[20];
  List imList,tempList;
  int imListSelected=0;
  int i=0;
  static TableList _instance;
  Command exitCmd,okCmd,downCmd,cancelCmd,helpCmd,closeCmd;

 static synchronized public TableList getInstance() {
    if (_instance == null) {
      _instance = new TableList();
    }
    return _instance;
  }

  public TableList() {
    GameInfo.waitFinished=false;
    imList=new List("Table list:",List.IMPLICIT);
    tempList=new List("temp list:",List.IMPLICIT);
    exitCmd=new Command("exit",Command.EXIT,1);
    okCmd=new Command("go on",Command.OK,1);
    cancelCmd=new Command("Cancel me",Command.CANCEL,1);
    closeCmd=new Command("close me",Command.EXIT,1);
    downCmd=new Command("download new servers list",Command.SCREEN,2);
    helpCmd=new Command("Help me",Command.HELP,1);
    imList.setCommandListener(this);
    imList.addCommand(exitCmd);
    imList.addCommand(helpCmd);
    imList.addCommand(okCmd);
    imList.addCommand(cancelCmd);
    imList.addCommand(closeCmd);
  }

  class MyTask extends TimerTask{
    public void run() {
     //create a new Thread
     Connect connectThread=new Connect();
     connectThread.start();
    }
  }

  public void downLoad(){
    Error.errCode=0;
    one=new Timer();
    oneTask=new MyTask();
    //GameInfo.display.setCurrent(Func.waitForm);
    GameInfo.waitFinished=false;
    GetServicData.imList=imList;
    GetServicData.imID=imID;
    one.schedule(oneTask,1,1000);
  return;
}


  private void downLoadTask(){
    String s1="";
    String s2="";
    GetServicData.url = "http://"+GameInfo.ServerAddress
                      + "/gameservice/infomationservice.asmx/GetPlayTableList?gameID="
                      + GameInfo.GameID+"&roomID="+GameInfo.RoomID;
    GetServicData.kind=3;
    System.out.println(GetServicData.url);
    int ss=imList.getSelectedIndex();
    GetServicData.imList=tempList;
    GetServicData.imID=imID;
    GetServicData.connect();
        int imListSize=imList.size();
        int tempListSize=tempList.size();
        int xx=tempListSize-imListSize;
        if (ss>(tempListSize-1)) {ss=tempListSize-1;}
        for (int i=1;i<=xx;i++){
          imList.append("ii",GetServicData.TableImage);
        }
        for (int i=0;i<tempListSize;i++){
          s1=tempList.getString(i);
          s2=imList.getString(i);
          if (s1!=s2){
            imList.set(i,"_"+s1,GetServicData.TableImage);
          }
        }
        if (ss>=0){
          imList.setSelectedIndex(ss,true);
        }
          GameInfo.display.setCurrent(imList);

    System.out.println("do table list once."+(i++));
  }

  public void commandAction(Command c, Displayable d) {
    if (c==cancelCmd){
      RoomList room=RoomList.getInstance();
      GameInfo.display.setCurrent(Func.waitForm);
      room.downLoad();
      one.cancel();
      _instance=null;
    }
    if (c==okCmd){
      one.cancel();
      int TableIndex=imList.getSelectedIndex();
      GameInfo.TableID=imID[TableIndex+1].toString();
      System.out.println("table ID="+GameInfo.TableID);
      _instance=null;
      WaitPlayer ww=WaitPlayer.getInstance();
      GameInfo.display.setCurrent(ww.waitPlayerCanvas);
      ww.waiting();
    }
  }

  class Connect extends Thread {
    public void run() {
       downLoadTask();
    }
  }
}

⌨️ 快捷键说明

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