コード例 #1
0
 /* Called when there's a change in the UserList model this class subscribes to
  *
  * @see org.soc.common.game.UserListChangedEventHandler#onUserListChanged(org.soc.common
  * .game.UserListChangedEvent) */
 @Override
 public void onUserListChanged(UserListChangedEvent event) {
   // List of users added
   if (event.getAddedUsers() != null)
     for (User newUser : event.getAddedUsers()) addItem(newUser.name());
   // Single user added
   if (event.getAddedUser() != null) addItem(event.getAddedUser().name());
   // User removed, search and destroy
   if (event.getRemovedUser() != null)
     for (int i = 0; i < this.getItemCount(); i++)
       if (getItemText(i).equals(event.getRemovedUser().name())) {
         removeItem(i);
         break;
       }
 }
コード例 #2
0
 @Override
 public void addUser(User userToAdd) {
   insertItem(userToAdd.name(), 0);
 }