This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTextPane Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextPane Questions" Watch "JTextPane Questions" New topic
Author

JTextPane Questions

Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

Hi Guys

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.

Cheers,
Riaan


"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
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

FYI, I have cross-posted my question on the Oracle forums, here; https://forums.oracle.com/forums/thread.jspa?threadID=2291596&stqc=true.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextPane Questions