Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display two JtestAreas contents alternatively handled by AWT-EventQueue-0 Thread  RSS feed

 
Karri Tata Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I'm developing Chat application GUI using SWING. My GUI has two JtestAreas one for displaying message that i was sent, and another for displaying replay coming from server. I was used Thread.sleep(1000) after message sent . Due to that, AWT-EventQueue-0 thread stops to display send message in first JtextArea and waits until it get response from server. After got response from server, in one shot, My GUI displays both JtetAreas Content.

But, I need to display send Message and Response Message in two different shots. I know the reason why it displays in one shot. Can I have solution from any one?


Thank you friends
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code that connects to the server needs to execute in a separate Thread.

Read the section from the Swing tutorial on Concurrency for more information. Maybe the SwingWorker is the best solution since it creates the Thread for you and you can just "publish" the server response as it becomes available and then update your GUI.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!