I\'m trying to create a client/server application. The problem is the confirm button on client side works for the first time input but if I hit the same button for the anoth
When you click on a button, the actionPerformed
method of your ActionListener
is triggered on the Event Dispatch Thread. This thread is the one-and-only thread responsible for the UI.
The UI will remain frozen until you leave the actionPerformed
method (as the thread is occupied). So if your ActionListener
blocks (e.g. with your fromServer.readLine()
call), the UI will remain frozen until that blocking call is ended.
That is why the general guideline is to offload long tasks to a worker thread. The Swing concurrency tutorial contains more information.