private void updateClientsForDevice(@Nullable IDevice device) { if (device == null) { // Note: we do want listeners triggered when the device itself disappears. // so we don't set myIgnoreListeners myClientsListModel.clear(); return; } Object selectedObject = myClientsList.getSelectedValue(); Client[] clients = device.getClients(); try { // we want to refresh the list of clients, however we don't want the listeners to // think that this is a user driven change to the list selection. // the only time this update should trigger the selection listener is if the currently // selected client isn't there anymore myIgnoreListeners = ArrayUtil.contains(selectedObject, clients); myClientsListModel.clear(); myClientsListModel.addAll(clients); myClientsList.setSelectedValue(selectedObject, true); } finally { myIgnoreListeners = false; } }