static void setComboBoxItems_notifyListeners(JComboBox cb, Cl items) {
if (cb != null) swing {
if (eq(getComboBoxItems(cb), items)) ret; // nothing to do
var sel = getSelectedItem_typed(cb);
setComboBoxItems(cb, items);
var item = getSelectedItem_typed(cb);
if (!eq(sel, item)) {
// restore old selection if possible
if (sel != null && contains(items, sel))
setSelectedItem(cb, sel);
else {
//printVars("combobox", +sel, +item);
// force onChange event(s) (need to use two events)
setSelectedItem(cb, (A) null);
setSelectedItem(cb, item);
}
}
}
}