void (final Component component, final ChangeListener listener, Disposable parentDisposable) { if (component instanceof CellEditorComponentWithBrowseButton) { addChangeListener(((CellEditorComponentWithBrowseButton<?>)component).getChildComponent(), listener, parentDisposable); } else if (component instanceof JTextField) { final DocumentAdapter documentListener = new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { listener.stateChanged(new ChangeEvent(component)); } }; final Document document = ((JTextField)component).getDocument(); document.addDocumentListener(documentListener); Disposer.register(parentDisposable, new Disposable() { @Override public void dispose() { document.removeDocumentListener(documentListener); } }); } else if (component instanceof JComboBox) { final ActionListener comboListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { listener.stateChanged(new ChangeEvent(component)); } }; ((JComboBox<?>)component).addActionListener(comboListener); Disposer.register(parentDisposable, new Disposable() { @Override public void dispose() { ((JComboBox<?>)component).removeActionListener(comboListener); } }); } else if (component instanceof JCheckBox) { final ActionListener checkBoxListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { listener.stateChanged(new ChangeEvent(component)); } }; ((JCheckBox)component).addActionListener(checkBoxListener); Disposer.register(parentDisposable, new Disposable() { @Override public void dispose() { ((JCheckBox)component).removeActionListener(checkBoxListener); } }); } else { throw new UnsupportedOperationException("editor control of type " + component.getClass().getName() + " is not supported"); } }