private synchronized void updateMainPanel(final GameModel newGameModel)
{
// This method is synchronized since it may be called by the client
// thread or by the GUI.
GameModel gameModel = newGameModel;
if (newGameModel == null)
{
try
{
gameModel = gameClient.getGameModelImmediately();
}
catch (RemoteException e)
{
e.printStackTrace();
gameModel = gameClient.getGameModel();
}
}
if (gameModel == null)
{
mainPanel.removeAll();
JLabel label = new JLabel(GUIMessages.NO_GAME_RUNNING_MESSAGE.toString());
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);
label.setOpaque(true);
label.setBackground(Color.BLUE);
label.setForeground(Color.WHITE);
gameModelDrawPanel = null;
mainPanel.add(label, BorderLayout.CENTER);
statusLabel.setText(GUIMessages.NO_GAME_RUNNING_MESSAGE.toString());
localGameModel = null;
}
else
{
if (localGameModel == null)
{
initFulfilledMainPanel(gameModel);
}
boolean bUpdatedGame = !gameModel.equals(localGameModel);
localGameModel = new GameModel(gameModel);
gameModelDrawPanel.updateModel(localGameModel);
PlayerMark mark = localGameModel.getCurrentPlayer();