I couldn't find out what is the problem here
Well, you've got this code executing in your UI thread:
while (true) {
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
clientSocket = serverSocket.accept();
...
}
...
}
So when you start your UI, it is basically hanging the UI thread. You can't block the UI thread like this - it should be in a separate thread, marshalling over to the UI thread when necessary (to update the UI).
See Concurrency in Swing for more details of the threading rules of swing.