|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
de.unibi.techfak.misc.GUIOutputStream
public class GUIOutputStream
This OutputStream is designed to reroute all output
written to it to a JTextArea. It is strongly recommended
to wrap this OutputStream with a PrintStream,
thus not every character has to be output, but the graphical component
is updated line by line.
This class comes with an internal buffer for storing data, which is
filled by the method write(int), and is not flushed
until it is full, or a "\n" has to be written, or the method
write(byte[], int, int) is called.
| Field Summary | |
|---|---|
private byte[] |
buffer
One block to hold the characters before they are send to the graphical component. |
private int |
filled
The fill state of the buffer. |
private javax.swing.JTextArea |
textComp
The JTextArea the output is redirected to. |
| Constructor Summary | |
|---|---|
GUIOutputStream(javax.swing.JTextArea tc)
Constructs this class by taking a graphical component to which all stream data is output using calls to append(String). |
|
| Method Summary | |
|---|---|
void |
flush()
Forces the output of the internal buffer. |
void |
write(byte[] b,
int offset,
int len)
Sets a new text for the graphical component by generating the text from flushing the internal buffer and the buffer given. |
void |
write(int b)
The byte is buffered, until one block of bytes come together or this byte is a '\n' (new-line) character. |
| Methods inherited from class java.io.OutputStream |
|---|
close, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private javax.swing.JTextArea textComp
private byte[] buffer
private int filled
| Constructor Detail |
|---|
public GUIOutputStream(javax.swing.JTextArea tc)
throws java.lang.NullPointerException
append(String).
tc - The graphical component the stream data are shown with.
java.lang.NullPointerException - If tc=null| Method Detail |
|---|
public void write(int b)
this.write(byte[], int, int)
write in class java.io.OutputStreamb - The byte to output.write(byte[], int, int)
public void write(byte[] b,
int offset,
int len)
write in class java.io.OutputStreamb - The byte buffer to output.offset - The first byte in the buffer that is to output.len - The number of bytes of the given buffer that are output.public void flush()
flush in interface java.io.Flushableflush in class java.io.OutputStream
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||