flush contents of JTextArea

T

trpost

I am using JTextArea to write the status of several URL's, there are
about 100 of them. I am writting the output to the JTextArea and
stdout. When I run through the loop (takes about 60 seconds) to get the
status, I see the results are instantly printed to stdout, but have to
wait for the execution to end before I see anything in the JTextArea.

I am writing to stdout using System.out.println("....") and writing to
JTextArea using textArea1.append("....")

Is there anything I can do to flush the results instantly to the
JTextArea like is done with System.out.println or are there any
inherent flush methods for a JTextArea?

Thanks
 
M

Matt Humphrey

I am using JTextArea to write the status of several URL's, there are
about 100 of them. I am writting the output to the JTextArea and
stdout. When I run through the loop (takes about 60 seconds) to get the
status, I see the results are instantly printed to stdout, but have to
wait for the execution to end before I see anything in the JTextArea.

I am writing to stdout using System.out.println("....") and writing to
JTextArea using textArea1.append("....")

Is there anything I can do to flush the results instantly to the
JTextArea like is done with System.out.println or are there any
inherent flush methods for a JTextArea?

I would bet that you're writing the results to your text area within the
EDT. It's busy doing your work instead of updating the screen. Put your
job into a thread and post updates back to the EDT.

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 
T

trpost

Thanks... Logically this makes sense, but I have not done much with
threads... I may need to read up a bit, but if you could provide a
quick example or reference, I would appreciate it.
 
K

Knute Johnson

I am using JTextArea to write the status of several URL's, there are
about 100 of them. I am writting the output to the JTextArea and
stdout. When I run through the loop (takes about 60 seconds) to get the
status, I see the results are instantly printed to stdout, but have to
wait for the execution to end before I see anything in the JTextArea.

I am writing to stdout using System.out.println("....") and writing to
JTextArea using textArea1.append("....")

Is there anything I can do to flush the results instantly to the
JTextArea like is done with System.out.println or are there any
inherent flush methods for a JTextArea?

Thanks

Show us some actual code. I've done a lot of what you describe and
never had too much delay. It will never be as fast as System.out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top