/** An impressive little bit of code from Lee Crawford at Twofish Technology (crawford@twofish.com). I want to be able to stream outout to a TextArea, much like a debugging console window. This wraps a stream around a TextArea.

This creates a stream that has its output pointing to the textArea. It turns out you only need to override write() to get this to work; the other methods eventually call that.

The JDK 1.1 spec wants you to use PrintWriter over PrintStreams, but (same song, 142nd verse) Netscape is only at the 1.02 stage. I don't think it would be hard to implement this over a PrintWriter. use it as follows: textAreaStream = new TextAreaStream (textArea); outputStream = new PrintStream (textAreaStream); [...] outputStream.println ("Button was pressed."); @author Don McGregor (http://www.npsnet.org/~mcgredo)

@version 1.0 */ package mil.navy.nps.awt; import java.awt.*; import java.io.*; public class TextAreaStream extends OutputStream { protected TextArea textArea; public TextAreaStream (TextArea textArea) { this.textArea = textArea; } public void write (int b) { // deprecated: file:///C|/jdk1.1.3/docs/api/java.awt.TextArea.html#appendText(java.lang.String) // textArea.appendText ("" + (char)b); textArea.append ("" + (char)b); } }