How to make JTextPane to show text line by line?

Hi,

I have the following code:

JTextPane myTextPane =new JTextPane();

.......

privatevoid myButtonActionPerformed(java.awt.event.ActionEvent evt)

{

for(int i=1; i<= 100; i++)

{

//Perform some database query here

executeDatabaseQuery();

this.myTextPane.setText(myTextPane.getText() +"Record " + i +" processed.");

}

}

I am trying to start some database query after myButton is pressed.

I would like the JTextPane (myTextPane) to show each query result text one by one after each query is executed.

However, when the above code is executed, the 100 lines of result text will only be displayed after all the 100 records are executed, and all the 100 rows of result text are shown at once.

This is not what I wanted.

Should I use some other Swing Component? If yes, what should I use?

Or is there a way to acheive this?

Thanks,

SK

[1313 byte] By [sk9a] at [2007-11-26 15:22:40]
# 1
Call the above code in a separate thread but the linethis.myTextPane.setText(myTextPane.getText() + "Record " + i + " processed.");inside SwingUtilities.invokeAndWait();regards,Stas
StanislavLa at 2007-7-8 21:37:49 > top of Java-index,Desktop,Core GUI APIs...
# 2
hi,Can you be more explicit? I do not quite understand what should be done?Thanks,SK
sk9a at 2007-7-8 21:37:49 > top of Java-index,Desktop,Core GUI APIs...
# 3
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
es5f2000a at 2007-7-8 21:37:49 > top of Java-index,Desktop,Core GUI APIs...