Samsquanch
Samsquanch

Reputation: 9146

Viewing styled text in a JTextPane as HTML

I've basically made a simple text editor with a JTextPane and some styling options (bold, italicize, underline, and center/right/left justify options), and I'm wondering if there is any easy way to view the HTML version?

What I'm eventually wanting to do is have an "export as HTML" type option that just has the plain text, but it's formatted with HTML tags instead of being styled.

Thanks

Upvotes: 1

Views: 625

Answers (2)

camickr
camickr

Reputation: 324207

If you want HTML, then you need to make sure the content type is text/html so the proper editor kit is used.

Then you use textPane.getText() to get the HTML.

Upvotes: 2

BigMac66
BigMac66

Reputation: 1538

Have you looked at any of the classes in javax.swing.text or javax.swing.text.html or javax.swing.text.html.parser?

Upvotes: 0

Related Questions