Object oldValue = event.getOldValue(); if (oldValue != null) { Document oldDoc = (Document) oldValue; oldDoc.removeDocumentListener(documentHandler); } Object newValue = event.getNewValue(); if (newValue != null) { Document newDoc = (Document) newValue; newDoc.addDocumentListener(documentHandler); }
    public void propertyChange(PropertyChangeEvent event)    {      if (event.getPropertyName().equals("document"))        {          // Document changed.	      modelChanged();        }      BasicTextUI.this.propertyChange(event);    }