code: public void detach()
      {
          textComponent.removePropertyChangeListener(
              documentPropertyChangeListener);
          Document document = textComponent.getDocument();
          document.removeUndoableEditListener(undoableEditListener);
          textComponent.getInputMap().remove(undoKeyStroke);
          textComponent.getActionMap().remove(DO_UNDO_NAME);
          textComponent.getInputMap().remove(redoKeyStroke);
          textComponent.getActionMap().remove(DO_REDO_NAME);
      }
docs: Detach this handler from the text component. This will remove all
  listeners that have been attached to the text component, its
  document, and the elements of its input- and action maps.