Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

New actions in HTMLEditorKit and JTextPane

 
andreas krohn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Eric Low
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!