public ChatterBoxUI() throws IOException
	{
		setSize(800, 600);
		setTitle("ChatterBox");
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);

		// add chat text display
		chatText = new JTextArea();
		chatText.setText("Welcome to ChatterBox!");
		//to enable the textarea to scroll to end automatically:
		DefaultCaret caret = (DefaultCaret)chatText.getCaret();
		caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
		
		add(new JScrollPane(chatText), BorderLayout.CENTER);

		// add panel with textbox and send button
		textbox = new JTextField(60);
		sendButton = new JButton("send");
		sendButton.addActionListener(new ActionListener()
		{
			@Override
			public void actionPerformed(ActionEvent arg0)
			{
				String text = textbox.getText();
				if (text != null && !"".equals(text))
				{
					// send to server if have connection
					if (socket != null)
					{
						try
						{
							out.write((text + "\n").getBytes()); // need the \n because readLine() blocks until it receives it
							out.flush(); // sends out the data
							//chatText.setText(chatText.getText() + "\nMe: " + text); //used when connecting to server ServerChatLD
							textbox.setText("");
						}
						catch (IOException e)
						{
							e.printStackTrace();
						}
					}
					else
					{
						chatText.setText(chatText.getText() + "\nNo connection to server - your message could not be sent");
						textbox.setText("");
					}
				}
			}
		});

		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout());
		panel.add(textbox);
		panel.add(sendButton, BorderLayout.EAST);
		add(panel, BorderLayout.SOUTH);

		// socket and related components remain null until a connection is made
		ChatClientThread conn = new ChatClientThread(this);
		conn.start();
	}