This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextPane Questions

 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FYI, I have cross-posted my question on the Oracle forums, here; https://forums.oracle.com/forums/thread.jspa?threadID=2291596&stqc=true.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic