public void login(boolean reconnect)
	{
			// ok it is a connection request
			name = tf.getText().trim();
			
			// empty username ignore it
			if(name.length() == 0)
				return;
			// empty serverAddress ignore it
			String server = tfServer.getText().trim();
			if(server.length() == 0)
				return;
			// empty or invalid port numer, ignore it
			String portNumber = tfPort.getText().trim();
			if(portNumber.length() == 0)
				return;
			int port = 0;
			try {
				port = Integer.parseInt(portNumber);
			}
			catch(Exception en) {
				return;   // nothing I can do if port number is not valid
			}

			// try creating a new Client with GUI
			
			client = new Client(server, port, name, this);
			// test if we can start the Client
			try {
				if(!client.start()) 
					return;
			} catch (BadLocationException e) {
				
				e.printStackTrace();
			}
		//	client.start_heartbeat();
			
			//Check gui version
			
		//	client.sendMessage(new ChatMessage(ChatMessage.VERSION, _guiVersion));
			
			
			
			tf.setText("");
			label.setText("Enter your message below");
			connected = true;
			
			// disable login button
			login.setEnabled(false);
			// enable the 2 buttons
			logout.setEnabled(true);
			whoIsIn.setEnabled(true);
			Nudge.setEnabled(true);
			// disable the Server and Port JTextField
			tfServer.setEditable(false);
			tfPort.setEditable(false);
			// Action listener for when the user enter a message
			tf.addActionListener(this);
			lblstatus.setText("Status : Connected");
			if (connected && !reconnect)
			{
				client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
			
				KeepAliveClient k = new KeepAliveClient(client);
				k.start();
			}
			}