protected void attemptConnection()
	{
		if (loadingLabel.isVisible())
			return; // If the loading label is visible, we are already attempting a connection.
		
		loadingLabel.setVisible(true);
		
		/* Reset error messages to hidden. */
		addressErrorLabel.setVisible(false);;
		nameErrorLabel.setVisible(false);
		passwordErrorLabel.setVisible(false);;
		
		String host = addressField.getText();
		String username = nameField.getText();
		String password = new String(passwordField.getPassword());
		
		boolean error = false;
		
		if (host.isEmpty())
		{
			addressErrorLabel.setText("Please provide a server address.");
			addressErrorLabel.setVisible(true);
			error = true;
		}
		else if (host.contains(" "))
		{
			addressErrorLabel.setText("Server address may not contain spaces.");
			addressErrorLabel.setVisible(true);
			error = true;
		}
		
		if (username.isEmpty())
		{
			nameErrorLabel.setText("Please provide a username.");
			nameErrorLabel.setVisible(true);
			error = true;
		}
		else if (username.contains(" "))
		{
			nameErrorLabel.setText("Usernames may not contain spaces.");
			nameErrorLabel.setVisible(true);
			error = true;
		}
		
		if (error)
		{
			loadingLabel.setVisible(false);
			return;
		}
		
		s = new ChatSession(host, username, password);
		s.open(this);
	}