@Override public void setSelectedItem(Object anItem) { if (Channel.MASTER.equals(anItem)) { selectedItem = Channel.MASTER; } else { int index = channels.indexByName(anItem); if (index < 0) { selectedItem = Channel.MASTER; } else { selectedItem = (String) anItem; } } ListDataEvent lde = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, -1, -1); fireListEvent(lde); }
public void intervalRemoved(ObservableListEvent<Channel> e) { if (channels.indexByName(selectedItem) < 0) { setSelectedItem(Channel.MASTER); } }