tags:

views:

1457

answers:

2

I currently have a program that prints lines of text to the screen in various manners such as 'System.out.println()' statements and for loops the print all elements in an array to screen.

I am now adding a GUI to this program. My problem is that I want to print everything that prints to eclipse's console to a textbox in my GUI instead. Is this possible and if so how would I go about doing this.

Thanks in Advance.

+2  A: 

An idea:

Create your own PrintStream that outputs everything to this textbox. Then set this new PrintStream to be the standard output stream like that:

System.setOut(myPrintStream());
romaintaz
would it be possible for you to give a bit more detail as to how I could implement this idea since the printing is happening in a seperate class? thanks.
Just look at the post given by theomega !
romaintaz
+3  A: 

Check this out http://unserializableone.blogspot.com/2009/01/redirecting-systemout-and-systemerr-to.html. The blog-article describes everything you need, its title is

Redirecting System.out and System.err to JTextPane or JTextArea

theomega
Thanks for the idea. This site seems to have the things it wants to print to the textarea in the same class as the gui. I want to keep the classes seperate.
so just separate the code into two classes!
romaintaz