register.java

来自「J2ME程序:手动设置URL主机地址和端口」· Java 代码 · 共 63 行

JAVA
63
字号


import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

public class Register implements Runnable{
	
	public gameStart  start;
	public String UserName = ""	;			//用户名
	public String UserPassword = "";		//密码
	Thread rt;
	String urlport="";
	
	
	
	public Register(gameStart g){
		start = g;
		rt=new Thread(this);
		
		
	}
	
	
	
	public void run() {	
		int inputStr=0;
			try{
				start.connection1.address="socket://"+start.url+":"+start.port;
			 	System.out.println("this is init net GAME_REGISTER");
			    start.connection1.SendUserInfo("97",start.UserName1,start.UserPassword1);
			    try{
				inputStr = Integer.parseInt(start.connection1.getOneData().substring(0,2));
	    	    }catch(Exception e){System.out.println("thsi is is is 11"+e);}
//				注册,1为成功,2为不成功
	    	    if(inputStr == 1){  
	    	    		//先显示“注册成功”的Alert,Alert显示完后显示“Gamemaincanvas”
	    	    	    start.display.setCurrent(new Alert("system message:","register sucessfully!",null, AlertType.ERROR));
	    	    		start.initMenu();
	    	    		start.Clear();
	    	    }else{
	    	    	start.display.setCurrent(new Alert("system message:", "connetion error!", null, AlertType.ERROR));
	    	    }
	    	 }catch(Exception e){
	    		 start.display.setCurrent(new Alert("system message:", "internet error!", null, AlertType.ERROR));
	    	     System.out.println("this is net Error!");
	    	 }
		
	}

		
		
		
		}
		
	

⌨️ 快捷键说明

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