Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

New actions in HTMLEditorKit and JTextPane

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to add new actions to my JTextPane using HTMLEditorKit, for example i want to have actions to add headers (H1 etc). I want these actions to function as the already existing BoldAction, ItalicAction etc. I have no problem in inserting the HTML, but i also want to be able to toggle it off and on (like BoldAction), ie if I select text within <H1> tags and once again press my H1 button i want the H1 tags to disappear. So far I havent had any luck with this.
Also when I get the attributes at a given caret position using doc.getCharacterElement(pos).getAttributes() i can only retreive the attributes that there are already actions for (bold, italic, underlined) and not my newly added headers. Annoying.
Does anyone have any ideas?
Thank you
/Andreas
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, this can be easily handled with Swing, try this:

Hope this helps!
Rgds
Eric Low
SCJP2
reply
    Bookmark Topic Watch Topic
  • New Topic