summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gui/TextAreaOutputStream.java
blob: a6eb57c8da6a56beb5134c014a80633505895947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package bjc.utils.gui;

import java.io.IOException;
import java.io.OutputStream;

import javax.swing.JTextArea;

/**
 * @author epr
 * @author Levente S\u00e1ntha (lsantha@users.sourceforge.net)
 */
public class TextAreaOutputStream extends OutputStream {

    private JTextArea textArea;

    public TextAreaOutputStream(JTextArea console) {
        this.textArea = console;
    }

    @Override
	public void write(int b) throws IOException {
        textArea.append("" + (char) b);
        if (b == '\n') {
            textArea.repaint();
        }
    }
}