Java swing GUI freezes

You have two pitfalls in your design:

  1. ss.accept() is a blocking call so your UI will freeze until there is an incoming connection
  2. Never run while(true) loops in the EDT.

Instead do the following:

  • When the button is clicked create a thread that will start listening for incoming connections.
  • Whenever you have an incoming connection, create another thread that will take the incoming client connection and deal with it.

Leave a Comment