final Value[] items,
final String regexp,
final Map<String, String> abbreviations) {
final List<Value> comboList = new ArrayList<Value>();
final Value selectedValueInfo = addItems(comboList, selectedValue, items);
final MComboBox<Value> cb = new MComboBox<Value>(comboList.toArray(new Value[comboList.size()]));
final JTextComponent editor = (JTextComponent) cb.getEditor().getEditorComponent();
if (regexp != null) {
editor.setDocument(new PatternDocument(regexp, abbreviations));
}
cb.setMaximumRowCount(CB_SCROLLBAR_MAX_ROWS);
if (selectedValueInfo != null) {
cb.setSelectedItem(selectedValueInfo);
}
/* workround, so that default button works */
editor.addKeyListener(new ActivateDefaultButtonListener<Value>(cb));
/* removing select... keyword */
editor.addFocusListener(new FocusListener() {
@Override
public void focusGained(final FocusEvent e) {
final Value v = getValue();
if (v == null || v.isNothingSelected()) {
editor.setText("");
}
}
@Override