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?
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.