import java.net.*;
import java.awt.*;
import java.io.*;

public class SocketInputArea extends TextField implements Runnable {
     Socket mySocket;
     PrintStream ps;
     

     SocketInputArea(Socket s) {
	  super();
	  mySocket = s;
     }
     SocketInputArea(int a, Socket s) {
	  super(a);
	  mySocket = s;
     }
     SocketInputArea(String st, Socket s) {
	  super(st);
	  mySocket = s;
     }
     SocketInputArea(String st, int a, Socket s) {
	  super(st, a);
	  mySocket = s;
     }
     
     public void run() {
	  try { ps = new PrintStream(mySocket.getOutputStream()); }
	  catch (Exception e) { }
     }

     public boolean action(Event evt, Object arg){
	  String msg = arg.toString();
	  if(ps != null){
	       System.out.println("Sending "+msg);
	       ps.println(msg);
	  }
	  else{
	       System.out.println("Oops...");
	  }
	  setText("");
	  return true;
     }
}	
