if (str.indexOf('\n') == -1)
if (str != null && str.indexOf('\n') == -1)
  protected Document createDefaultModel()  {    // subclassed to swallow newlines    return new PlainDocument() {        public void insertString(int offset, String str, AttributeSet a)          throws BadLocationException        {          if (str.indexOf('\n') == -1)            super.insertString(offset, str, a);        }      };  }