Element elem = textComponent.getDocument().getDefaultRootElement();
if (factory == null) return; Document doc = textComponent.getDocument(); if (doc == null) return; Element elem = doc.getDefaultRootElement(); if (elem == null) return;
  protected void modelChanged()  {    ViewFactory factory = rootView.getViewFactory();    Element elem = textComponent.getDocument().getDefaultRootElement();    setView(factory.create(elem));  }