You can change the font of JTextPane only in general, it does not have rich text.
There is a Document under JEditorPane (and, obviously, JTextPane), which you get with getDocument() . You want to do this with StyledDocument if you can, and then you can do something like setCharacterAttributes for a given character range.
There are several (hopefully) useful examples in the Java tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html .
source share