if (oldDoc != null) oldDoc.removeDocumentListener(repaintListener); if (newDoc != null) newDoc.addDocumentListener(repaintListener);
  public void setDocument(Document newDoc)  {    Document oldDoc = doc;    doc = newDoc;    // setup document listener    if (oldDoc != null)      oldDoc.removeDocumentListener(repaintListener);    if (newDoc != null)      newDoc.addDocumentListener(repaintListener);    firePropertyChange("document", oldDoc, newDoc);	revalidate();	repaint();    }