[5026] in java-interest

home help back first fref pref prev next nref lref last post

Re: problems hooking up a TextArea to a DataInputStream

daemon@ATHENA.MIT.EDU (Francois Boussard)
Fri Jan 26 07:11:31 1996

From: Francois Boussard <francois@coplanet.fr>
Date: Fri, 26 Jan 1996 11:30:44 GMT
To: java-interest@java.sun.com

	Hum , i've not the answer to your problem, but it's seems to me 
that the star() method should not call start() ? 
 
> public class LineMode extends Applet implements Runnable {
>     private Socket socket;
>     private DataInputStream in;
>     private TextArea outputArea;
>     private Thread engine = null;
> 
>     public void init() {
> 	Panel blah = new Panel();
> 	setLayout(new BorderLayout());
> 	add("Center", blah);
> 	outputArea = new TextArea(24,80);
> 	blah.add(outputArea);
> 
> 	// I've deleted all the exception stuff for brevity.
> 
> 	socket = new Socket("xxx", 7777); // or whatever
> 	in = new DataInputStream(socket.getInputStream());
>     }
> 
>     public void start() {  //  This is where I'm screwing up I suspect.
> 	if (engine == null) {
> 	    engine = new Thread(this);

> 	    engine.start();

	    ^^^^^^^^^^^^^^^ 
	    Here, you launch a recursive loop of thread creation ... ?



> 	}
>     }
> 
>     public void run() {
> 	String line;
> 
> 	try { line = in.readLine(); }
> 	catch (Exception e) { line = null; }
> 
> 	if (line != null) { outputArea.appendText(line); }
> }
> 
> // EOF
> --
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post