I've been trying to do this for weeks now, and can't seem to get it to work. I have a JTextPane called textArea2, and I have a variable called doc that gets the document from the textpane. I want to get the selected text but I can't get no code to work. I've posted in a lot of forums and no one will help me.
This is the code I have so far:
public void processBoldText()
{
MutableAttributeSet mas = new SimpleAttributeSet();
Font f = new Font ("SansSerif", Font.BOLD, 20);
StyleConstants.setBold(mas,f.isBold());
int offset = textArea2.getSelectionStart();
int end = textArea2.getSelectionEnd();
int length = end - offset;
doc.setCharacterAttributes(offset,length,mas,false);
}
I get an error message saying cannot find symbol, method setcharacter attributes(and ithen it lists the arguments)