void (Object obj) { String newItem = ((String)obj).trim(); if (newItem.isEmpty()) { return; } if (!contains(newItem)) { // set newly added item as selected. // otherwise current selection will be set to editor mySelectedItem = newItem; insertElementAt(newItem, 0); } }