bind system.out stream to SWT text widget [message #454473] |
Thu, 21 April 2005 13:38  |
Eclipse User |
|
|
|
Hi,
I'm trying to figure out how I can bind the system.out stream to a swt
text widget. I've figured out that I can use System.setOut() to redirect
the stream. But now I'm stuck at trying to get it connected to a text
widget. Does anyone have any hints or code examples?!
|
|
|
|
|
|
Re: bind system.out stream to SWT text widget [message #1844245 is a reply to message #1844167] |
Tue, 07 September 2021 01:42  |
Eclipse User |
|
|
|
This is very easy to do!
First extend PrintStream as follows;
public class YourPrintStream extends PrintStream {
and implement the following methods inside this class to display your message on your SWT widget. That is, implement write() to display on your widget.
public void write(int b) {
public void write(byte[] buf, int off, int len) {
public void close() {
Finally in the beginning, instantiate this extended class and set for out and err as follows;
YourPrintStream f3 = new YourPrintStream(,,,);
System.setOut(f3);
System.setErr(f3);
|
|
|
Powered by
FUDForum. Page generated in 0.02880 seconds