We're trying to build a simple WYSIWYG HTML editor using a JTextPane. I've used Charles Bell's example as a reference. My biggest gripe with it at the moment is that bullets aren't working as I would expect them to. If I highlight text and click the "Bullet" button, I want a bullet to be placed immediately before the highlighted text, on the same line. If I try to do this, my code is creating bullets, but it moves the selected text one line down. I've gone through the Oracle tutorial on text components, but I couldn't find anything that helped me with this particular issue.
Also, if I copy and paste text into my JTextPane, the pasted text always appears on a new line (a new <p></p> tag in the actual HTML). Is there a way to prevent the JTextPane from creating new paragraphs?
Lastly, I'm flabbergasted as to why my buttons actually work. I can't see anything that explicitly links my buttons to my HTMLEditorKit or my JTextPane. Short of a little voodoo priest living under my keyboard, how on earth do my buttons/actions know that they should update the JTextPane?
The code is as follows;
I'd really appreciate your inputs on this.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw