try {
StyledDocument doc = new DefaultStyledDocument();
doc.insertString(0, "This is the beginning text", null);
doc.insertString(doc.getLength(), "\nInserting new line at end of doc", null);
MutableAttributeSet attrs = new SimpleAttributeSet();
StyleCons...