@Override
    public void update(Observable o, Object arg) {
        if (o instanceof ChatConnection) {
            if (arg instanceof ChatMessage) {
                // Display the message. It's from another user.
                mainTextArea.append(((ChatMessage) arg).getSender() + ": " + ((ChatMessage) arg).getMessage() + "\n");
                mainTextArea.setCaretPosition(mainTextArea.getDocument().getLength());
                log.messageReceived((ChatMessage) arg);
            } else if (arg instanceof ChatPerson) {
                // Someone joined the room.
                System.out.println(((ChatPerson) arg).getName());
                // Notify us of user connection. TODO Also add user to list
                mainTextArea.append(((ChatPerson) arg).getName() + " has entered\n");
                mainTextArea.setCaretPosition(mainTextArea.getDocument().getLength());
                log.personLoggedIn((ChatPerson) arg);
                list.addPerson((ChatPerson) arg);
            } else if (arg instanceof ServerMessage) {
                // Message from server. Display special message depending on contents.
                ServerMessage message = (ServerMessage) arg;
                processMessage(message);
                log.serverMessageReceived((ServerMessage) arg);
            }
        }
    }