Changing the font of a JEditorPane
Hello all,
Anyone know how to change the font of a JEditorPane, i have done this already:
Font font =new Font("Helvetica", Font.PLAIN, 55);
displayEditorPane.setFont(font);
(where displayEditorPane is the JEditorPane)
The above doesn't work for some reason, can anyon tell me why or any other suggestions for doing it differently.
Thanks all, :)
[449 byte] By [
abshirf2a] at [2007-11-27 2:03:46]

# 1
JEditorPane doesn't use the font. instakked EditorKit defines how the content will be rendered. You know JEditorPane may contain several fragments of text with different fonts.
So set proper EditorKit (e.g StyledEditorKit).
Get the document and cast it to StyledDocument
define SimpleAttributeSet and set proper font attributes by StyleConstants.setFontSize(), StyleConstants.setFontFamily() etc.
then insert a string in the document with the specified attributes
or use setCharacterAttributes() method to apply the attributes to existing text.
regards,
Stas