PDA

View Full Version : Java - live JTextArea append


Yakisoba
09-20-2006, 08:30 AM
I have a JTextArea that I would like to have updated as strings are appended to it.

for example, I have this function:

public void updateMessageCenter(String message){
this.outTextArea.append(message + newline);

}


whenever this:

updateMessageCenter("this would be the message");


is called I would like it to display in the text area.

Note: the append works, but it only displays the result AFTER the program has finished executing.

Any suggestions?


Yak

Aradon
09-21-2006, 07:43 AM
I think you're looking for something like a change listener.

http://java.sun.com/docs/books/tutorial/uiswing/events/changelistener.html

I think.

Yakisoba
09-21-2006, 09:08 AM
hmmm...

I don't think that is quite what I am looking for.

The append object I use updates the contents of the textarea properly, however it doesn't display line-by-line (only displays when the program is finished running).

What I'm thinking I'll need is to call a paintComponent() on that textarea every time updateMessageCenter is called. Problem is I have a bunch of components on the screen right now and need to determine which ones need to be redrawn and when.

could be completly wrong though...any more suggestions?

Yak