You have two pitfalls in your design:
ss.accept()
is a blocking call so your UI will freeze until there is an incoming connection- 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.