void (final Editor editor) { if (myLastEditor != editor) { if (myLastEditor != null) { myLastEditor.removeEditorMouseListener(myEditorMouseListener); myLastEditor.getDocument().removeDocumentListener(myEditorDocumentListener); myLastEditor.getScrollingModel().removeVisibleAreaListener(myVisibleAreaListener); myLastEditor.getCaretModel().removeCaretListener(myCaretMoveListener); myLastEditor.getSelectionModel().removeSelectionListener(mySelectionListener); } myLastEditor = editor; if (myLastEditor != null) { myLastEditor.addEditorMouseListener(myEditorMouseListener); myLastEditor.getDocument().addDocumentListener(myEditorDocumentListener); myLastEditor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener); myLastEditor.getCaretModel().addCaretListener(myCaretMoveListener); myLastEditor.getSelectionModel().addSelectionListener(mySelectionListener); } } }