diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-10-20 18:32:40 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-10-20 18:32:40 -0400 |
| commit | 9e090ec2a5dca83883e7a61d8822cd09b02f3881 (patch) | |
| tree | 7a4797e9d88b402e5ef5fdec1792f1efe15c14f4 /base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java | |
| parent | f2702a50a2b7e27ba46c44101edfc737f8eb54ac (diff) | |
Move TextAreaOutputStream
It seemed like it was more sensible to put this class in with the other
IO related things, instead of in with the GUI stuff
Diffstat (limited to 'base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java b/base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java new file mode 100644 index 0000000..10f5104 --- /dev/null +++ b/base/src/main/java/bjc/utils/ioutils/TextAreaOutputStream.java @@ -0,0 +1,35 @@ +package bjc.utils.ioutils; + +import java.io.IOException; +import java.io.OutputStream; + +import javax.swing.JTextArea; + +/** + * An output stream that prints to a JTextArea + * + * @author epr + * @author Levente S\u00e1ntha (lsantha@users.sourceforge.net) + */ +public class TextAreaOutputStream extends OutputStream { + private final JTextArea textArea; + + /** + * Create a new output stream attached to a textarea + * + * @param console + * The textarea to write to + */ + public TextAreaOutputStream(final JTextArea console) { + this.textArea = console; + } + + @Override + public void write(final int b) throws IOException { + textArea.append("" + (char) b); + + if (b == '\n') { + textArea.repaint(); + } + } +} |
