This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
So far so good, but now I have a weird combination of facts...
- If I only start the Serverwindow without the Launcher: No problem - If I try to start Serverwindow and Clientwindow at the same time: Only Serverwindow appears - If I start Serverwindow with the Launcher (JFrame): Both frames freeze and program hangs - If I start Serverwindow without the while loop: No problem
Roseanne is right, of course, but I can make a good guess: you put the "accept()" loop above right into an event handler of your GUI. Note that all events get handled on the same thread; by putting an infinite loop in an event handler, you prevent the GUI from ever receiving another event, and so the program appears to "freeze".
There's no way around it: you must create a dedicated thread for the server loop to run in. You probably have to do the same thing for the client, if the client sits in a loop reading and writing. Since you're apparently already creating threads to handle the server connections, this shouldn't be a problem for you.