public void actionPerformed(ActionEvent e)
	{
		Object o = e.getSource();
		
		// if it is the logout button
		if(o == logout)
		{
			_client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, ""));
			return;
		}
		// if it is the whoIsIn button
		if(o == whoIsIn)
		{
			_client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
			return;
		}
		
		// ok it is coming from the JTextField
		if(connected)
		{
			// just have to send the message
			_client.sendMessage(new ChatMessage(ChatMessage.MESSAGE, tf.getText()));
			tf.setText("");
			return;
		}
		
		// if it is the login button
		if(o == login)
		{
			// ok it is a connection request
			String username = tf.getText().trim();
			// if empty username, ignore it
			if(username.length() == 0)
				return;
			// if empty server address, ignore it
			String server = tfServer.getText().trim();
			if(server.length() == 0)
				return;
			// if empty or invalid port number, 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, username, this);
			// test if we can start the Client
			if(!_client.start())
				return;
			tf.setText("");
			label.setText("Enter your message below");
			connected = true;
			
			// disable the login button
			login.setEnabled(false);
			// enable logout and whoIsIn button
			logout.setEnabled(true);
			whoIsIn.setEnabled(true);
			// disable the Server and Port JTextField
			tfServer.setEditable(false);
			tfPort.setEditable(false);
			// add ActionListener for when the user enters a message
			tf.addActionListener(this);
		}		
	}