I have this game using a Client & Server with sockets. When a client starts it requests a Room list of all currently available Rooms which then the client puts in a JList using a DefaultListModel. Then when the client selects one of the Rooms it sends a request to the Server to join this Room. Then the Server replies back with an Object containing all the Players that are currently in this Room. The client then updates the JList like this:
As you can see basically all the current elements currently in the DefaultListModel are removed and then the newly received Players are added to the DefaultListModel.
But sometimes the JFrame does not update the JList properly and it appears empty but it did printout the message "..... added to the Playerlist"..
Example: Player A connects to the Server and joins Room 0. Now the JList is always gets updated properly!! Then Player B connects to the server and joins Room 0 as well. Then the server broadcasts the current players in Room 0 back to the Clients(Player A and B).
Player A does receive the update(according to the printed out console messages) but the JList is not updated(this is actually where the problem occurs but it does not always happen!).
Player B also receives the update and the JList is always updated properly.
That's not necessary because DefaultListModel already triggers an event that should cause a visual update to the GUI. I think Michael and Rob are right. Concurrency in Swing explains it all.