import java.applet.Applet;
import java.awt.*;

public class TClient extends Applet {
    TextArea textArea;
    TextField textField;
    Button sendButton;

    /**
     * Called if an action occurs in the Component
     * @param evt the event
     * @param what the action that's occuring
     * @see java.awt.Component#action
     */
    public boolean action(Event evt, Object what) {
	if(evt.target == textField) {
	    send();
	    return true;
	}
	if(evt.target == sendButton) {
	    send();
	    return true;
	}
	return false;
    }

    public void init() {
	
	GridBagLayout layout=new GridBagLayout();
	GridBagConstraints constraints=new GridBagConstraints();
	setLayout(layout);

	constraints.fill = GridBagConstraints.BOTH;
	constraints.weightx = 1.0;
	
	textField = new TextField("");
	layout.setConstraints(textField,constraints);
	add(textField);
	
	constraints.gridwidth = GridBagConstraints.REMAINDER;
	sendButton = new Button("SendButton");
	sendButton.setLabel("Send");
	layout.setConstraints(sendButton,constraints);
	add(sendButton);
	
	constraints.weightx = 0.0;
	textArea = new TextArea("");
	textArea.setEditable(false);
	layout.setConstraints(textArea,constraints);
	add(textArea);
	
    }

    public void send() {
	TSpawnClient client = new TSpawnClient(textArea,textField);
	client.start();
    }

    public void run() {
    }
}
