private static ChatInput chat = new ChatInput(4,30,30);
public static void main(String[] args)
{
Client service;
ConnectBoard theBoard;
String a,b,d;
int c;
a=input("127.0.0.1","Enter the IP of the server you will connect to");
b=input("8080","Enter the port number that you will connect to");
c=Integer.parseInt(b);
d=input("Player","Enter the name you want to go by on the server");
while(true)
{
try
{
service = new Client(d,a,c,chat);
} catch(UnknownHostException ex) {
alert("Bad host","Trying to connect to unknown host.");
return;
} catch(IOException ex) {
alert("Error","There has been an error");
return;
} catch(Exception ex) {
alert("Error","Unknown error");
return;
}
theBoard = service.getBoard();
if(theBoard==null)
{
alert("Error","Server connection error");
return;
}
chat.addClickListener(new ChatListener(service,chat));
for(int i=0;i<theBoard.getRows();i++)
{
for(int j=0;j<theBoard.getCols();j++)
{
JButton temp =theBoard.getCellButton(i,j);
temp.addActionListener(new GridFunction(i,j,service));
}
}
setUp(theBoard,theBoard.getRows(),theBoard.getCols());
service.notifyEnd();
if(ask("Again?","Play again?")==1) break;
}