F
François R
I redirect system.out to a JTextArea with the following class
private class TextAreaOutputStream extends OutputStream {
JTextArea textArea;
TextAreaOutputStream(JTextArea textArea) {
this.textArea = textArea;
}
public void flush() {
textArea.repaint();
}
public void write(int b) {
//try {
textArea.append(new String(new byte[] {(byte)b}));
// } catch (UnsupportedEncodingException e){e.printStackTrace();}
}
}
and I use the class with
JTextArea msg = new JTextArea();
System.setOut(new PrintStream(new TextAreaOutputStream(msg), true));
This works well except when I have a character like Č (latin capital
letter C with caron, '\u010C') in a string, which is displayed as ? in
the text area whereas
msg.append(string); would be ok.
How could I correct the code above to have such a letter well
formed ?
Thanks
François
private class TextAreaOutputStream extends OutputStream {
JTextArea textArea;
TextAreaOutputStream(JTextArea textArea) {
this.textArea = textArea;
}
public void flush() {
textArea.repaint();
}
public void write(int b) {
//try {
textArea.append(new String(new byte[] {(byte)b}));
// } catch (UnsupportedEncodingException e){e.printStackTrace();}
}
}
and I use the class with
JTextArea msg = new JTextArea();
System.setOut(new PrintStream(new TextAreaOutputStream(msg), true));
This works well except when I have a character like Č (latin capital
letter C with caron, '\u010C') in a string, which is displayed as ? in
the text area whereas
msg.append(string); would be ok.
How could I correct the code above to have such a letter well
formed ?
Thanks
François