Reputation: 63
I am trying to create a panel while I have already connected to a server with socket, but in java it shows frame but not inside of frame. Panel is only shown after socket closed, but I need it while it is open. How can I solve this? It is because of a thread problem or I just missing something.... Thanks...
Upvotes: 4
Views: 168
Reputation: 44240
Long-running tasks should never occur on the EDT. This includes blocking I/O operations. If such tasks do not modify any Swing components, simply use another thread. Otherwise, there are utilities available (e.g. SwingWorker
and SwingUtilties
) that will enable to you carry out long-running tasks in another thread, and then post the result as an action event on the EDT to modify any Swing components.
See also:
Upvotes: 5