Possible Duplicate:
How I append text to textarea with using swingworker class?
I append my jtextarea many lines in for loop. When i add lines , I dont see any line on text but when the for loop finish all of them is showing up. How can I see the every each line one by one ?
Don't execute your process in the Event Dispatching Thread, it blocks the repaint updates from occurring.
You should make use of the SwingWorker API
Also, take a look at
Let me guess what you're doing
while (doSomeWork) {
// do some processing
textArea.append(someText);
}
Or possibly a for
loop
And you're, some how expecting the UI to magically be updated?
Unfourtantly, as much as I would love it to work like that, it doesn't work that way.
In order for the screen to be updated, you must allow the Event Dispatching Thread to continue running, so it can handle repaint requests (& a bunch of other important things), you need to off load your processing to another thread.
No, there isn't any other way to it, & the easiest way is to use the SwingWorker