I know that I can set the font family in an AttributeSet as follows:
SimpleAttributeSet set = new SimpleAttributeSet();
StyleConstants.setFontFamily(set, "Monospace");
doc.insertString(
caretPosition, text, set);
But I really want to set the font:
StyleConstants.setFont(set, "Courier New");
However, there is no StyleConstants.setFont () method.
So how do I set the font in an AttributeSet? (Note that I'm free to use an AttributeSet implementation other than SimpleAttributeSet. I just used this one.)
(Note that my real goal is to insert a line into the document using the specified font.)
source
share