public void dialogClose(Login login, boolean register) {
		String password = login.passwordField.getText().trim();
		if (register)
		{
			JPanel panel = new JPanel();
			JLabel label = new JLabel("Verify password: ");
			final JPasswordField pass = new JPasswordField(15);
			panel.add(label);
			panel.add(pass);
			pass.requestFocus();
			ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
			scheduler.schedule(new Runnable() {
				public void run()
				{
					pass.requestFocus();
				}
			}, 100L, TimeUnit.MILLISECONDS);
		    int option = JOptionPane.showConfirmDialog(login, panel, "Register", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
			if(option != JOptionPane.OK_OPTION)
			  return;

		    String result = new String(pass.getPassword()).trim();
			if (!password.equals(result))
			{
				JOptionPane.showMessageDialog(login,
					    "You entered different passwords!",
					    "Register",
					    JOptionPane.ERROR_MESSAGE);
				return;
			}
		}
		String team = login.getTxtTeamName().getText();
		
		team = team.trim().replace("#", "").replace(":","");
		if(team.length() > 128) {
			team = team.substring(0,128);
		}
		
		String ip = login.getTxtServerIpAddress().getText().trim();
		if(team.length() > 0) {
			login.setVisible(false);
			ClientMessages serverSock;
			if ((serverSock = initializeConnection(ip)) != null) {
				GUI.setTeamName(team);
				setIP(ip);
				operator = new ClientOperator(this, team, serverSock);
				GUI.setOperator(operator);
			    serverSock.sendLogin(register, team, password);
			}
			else
			{
				JOptionPane.showMessageDialog(login,
					    "Failed to connect to server.",
					    "Connect",
					    JOptionPane.ERROR_MESSAGE);
				login.setVisible(true);
			}
		}
	}