<commit_before>/**
 *		Client is a chat client for the accompanying server.
 *		It gets the hostname and port to connect to from the user, and then acts
 *		as a GUI frontend to some sockets.
 */

// For networking
import java.net.*;
import java.io.*;
import java.util.*;

// For GUI
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Client extends JFrame implements ActionListener
{
	// IO elements that need to be accessed in several methods
	private static JTextArea display;
	private static JTextField input;
	private static PrintWriter outs;

	// Plays sound effects for client events
	private static SoundPlayer sounds;

	// This is the window where the user enters port number and hostname
	private static ClientSetup setup;

	// This is true when we're ready to read / write data to the network
	private static boolean initialized = false;

	// Sets up the GUI elements, called once during setup
	public Client(String host)
	{
		setTitle("Chat Client");
		setSize(350, 220);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		sounds = new SoundPlayer();

		display = new JTextArea("Connecting to host: " + host);
		display.setLineWrap(true);
		JScrollPane scroll = new JScrollPane(display);
		input = new JTextField();
		input.addActionListener(this);

		display.setEditable(false);

		this.setLayout(new BorderLayout());
		this.add(scroll, BorderLayout.CENTER); // Center makes it use all space
		this.add(input, BorderLayout.SOUTH);
	}

	// This is called whenever the user presses return in the input box
	public void actionPerformed(ActionEvent event)
	{
		Object source = event.getSource();
		if( !source.equals(input) || initialized == false )
			return;
		String text = input.getText().trim(); 	// Get the text user has entered
		input.setText(new String("")); 			// Clear text box
		if( text.length() > 0 )
			outs.println(text);					// Send text across the network
	}

	// This is called to connect to a server and read from the socket
	private void connectToServer( InetAddress host, int port )<commit_msg>Updated default window size<commit_after>/**
 *		Client is a chat client for the accompanying server.
 *		It gets the hostname and port to connect to from the user, and then acts
 *		as a GUI frontend to some sockets.
 */

// For networking
import java.net.*;
import java.io.*;
import java.util.*;

// For GUI
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Client extends JFrame implements ActionListener
{
	// IO elements that need to be accessed in several methods
	private static JTextArea display;
	private static JTextField input;
	private static PrintWriter outs;

	// Plays sound effects for client events
	private static SoundPlayer sounds;

	// This is the window where the user enters port number and hostname
	private static ClientSetup setup;

	// This is true when we're ready to read / write data to the network
	private static boolean initialized = false;

	// Sets up the GUI elements, called once during setup
	public Client(String host)
	{
		setTitle("Chat Client");
		setSize(355, 220);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		sounds = new SoundPlayer();

		display = new JTextArea("Connecting to host: " + host);
		display.setLineWrap(true);
		JScrollPane scroll = new JScrollPane(display);
		input = new JTextField();
		input.addActionListener(this);

		display.setEditable(false);

		this.setLayout(new BorderLayout());
		this.add(scroll, BorderLayout.CENTER); // Center makes it use all space
		this.add(input, BorderLayout.SOUTH);
	}

	// This is called whenever the user presses return in the input box
	public void actionPerformed(ActionEvent event)
	{
		Object source = event.getSource();
		if( !source.equals(input) || initialized == false )
			return;
		String text = input.getText().trim(); 	// Get the text user has entered
		input.setText(new String("")); 			// Clear text box
		if( text.length() > 0 )
			outs.println(text);					// Send text across the network
	}

	// This is called to connect to a server and read from the socket
	private void connectToServer( InetAddress host, int port )
{'fraction_non_alphanumeric': 0.0930683470673776, 'fraction_numerical': 0.0033931168201648087, 'mean_word_length': 3.855294117647059, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4278049', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1151, 'n_words': 475}