try{ Document doc = textPane.getDocument(); doc.insertString(doc.getLength(), "bla", style);}catch (BadLocationException e) {}