Turning on and off character attributes in a JTextPane
What I am trying to do seems pretty simple but I just can't get it and I've been struggling with this for days now. Searched everywhere.
I created a class called WrapTextPane that extends JTextPane so that I can turn on and off text wrapping and that works great. I also have created several styles and added them to the created WrapTextPane so I can use them with the insertString method of the associated styled document for various effects (font type and size, color, etc.) and that also works great. However, now I want to be able to turn on and off various character attributes like bold, underline, italics, etc. by toggling a button on the screen. I can't do it! One method I thought might work would be to use key event listeners to intercept the entered character and apply the attributes to it but can't make that work either.
This sort of thing is done all the time. What am I missing?
No sooner did I post this that I finally found something that looks promising. I'm trying to use the styled document setCharacterAttributes method. Is that how you would do it?
Ok that didn't work. Anyone have any ideas?