Results 1 to 1 of 1
- 10-12-2011, 02:00 AM #1
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?
Last edited by madroadbiker; 10-14-2011 at 01:28 AM.
- By imorio in forum New To JavaReplies: 3Last Post: 01-01-2011, 05:58 PM
- By gib65 in forum Advanced JavaReplies: 4Last Post: 08-25-2010, 03:58 PM
- By Nightshadow_t2 in forum New To JavaReplies: 3Last Post: 02-17-2010, 09:03 AM
- By BugginVT in forum New To JavaReplies: 7Last Post: 02-25-2009, 08:38 AM
- By Defero in forum New To JavaReplies: 0Last Post: 07-19-2008, 09:09 PM