void (final Component parentComponent) { if (parentComponent instanceof JTextComponent) { ((JTextComponent)parentComponent).getDocument().addDocumentListener(myDocumentListener); } else if (parentComponent instanceof EditorTextComponent) { ((EditorTextComponent)parentComponent).addDocumentListener(myIdeaDocumentListener); } else if (parentComponent instanceof ItemSelectable) { ((ItemSelectable)parentComponent).addItemListener(myItemListener); } else if (parentComponent instanceof JList) { ((JList)parentComponent).getModel().addListDataListener(myListDataListener); if (trackListSelection()) ((JList<?>)parentComponent).addListSelectionListener(myListSelectionListener); } else if (parentComponent instanceof JTree) { ((JTree)parentComponent).getModel().addTreeModelListener(myTreeModelListener); } if (parentComponent instanceof JComboBox) { ComboBoxEditor editor = ((JComboBox<?>)parentComponent).getEditor(); if (editor != null) { register(editor.getEditorComponent()); } } if (parentComponent instanceof JTable table) { table.addPropertyChangeListener("model", myTableListener); TableModel model = table.getModel(); if (model != null) { model.addTableModelListener(myTableModelListener); } table.addPropertyChangeListener(TABLE_CELL_EDITOR_PROPERTY, myCellEditorChangeListener); } if (parentComponent instanceof JSlider) { ((JSlider)parentComponent).addChangeListener(myChangeListener); } UserActivityProviderComponent provider = getActivityProviderComponent(parentComponent); if (provider != null) { provider.addChangeListener(myChangeListener); } }