Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically refresh JTextArea as processing occurs?

Tags:

I am trying to create a very simple Swing UI that logs information onto the screen via a JTextArea as processing occurs in the background. When the user clicks a button, I want each call to:

textArea.append(someString + "\n"); 

to immediately show up in the UI.

At the moment, the JTextArea does not show all log information until the processing has completed after clicking the button. How can I get it to refresh dynamically?

like image 235
digiarnie Avatar asked Mar 10 '09 08:03

digiarnie


1 Answers

Try this:

jTextArea.update(jTextArea.getGraphics()); 
like image 56
petr Avatar answered Nov 11 '22 14:11

petr