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 开发者_Python百科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
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.
Have you looked at any of the classes in javax.swing.text or javax.swing.text.html or javax.swing.text.html.parser?
精彩评论