SimpleAttributeSet atts = new SimpleAttributeSet(); atts.addAttribute(StyleConstants.ComponentAttribute, component); atts.addAttribute(StyleConstants.NameAttribute, StyleConstants.ComponentElementName); try { getDocument().insertString(getCaret().getDot(), " ", atts); } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location"); err.initCause(ex); throw err; }
  public void insertComponent(Component component)  {    // TODO: One space must be inserted here with attributes set to indicate    // that the component must be displayed here. Have to figure out the    // attributes.  }