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 prob开发者_高级运维lem or I just missing something.... Thanks...
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:
- Concurrency in Swing
精彩评论