Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default 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.

Similar Threads

  1. turning an ArrayList into an Array
    By imorio in forum New To Java
    Replies: 3
    Last Post: 01-01-2011, 05:58 PM
  2. turning off key-repeat
    By gib65 in forum Advanced Java
    Replies: 4
    Last Post: 08-25-2010, 03:58 PM
  3. Turning a Bug around.
    By Nightshadow_t2 in forum New To Java
    Replies: 3
    Last Post: 02-17-2010, 09:03 AM
  4. Turning numbers into asterisks.
    By BugginVT in forum New To Java
    Replies: 7
    Last Post: 02-25-2009, 08:38 AM
  5. JTextPane (reading char and its attributes)
    By Defero in forum New To Java
    Replies: 0
    Last Post: 07-19-2008, 09:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •