void (ComboBox<String> comboBox) { final ComboBoxEditor boxEditor = comboBox.getEditor(); if (boxEditor != null) { final Component component = boxEditor.getEditorComponent(); if (component instanceof JTextField) { ((JTextField)component).getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { updateOkAction(); } }); } } comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateOkAction(); } }); }