Hi to all,
I would like to display HTML source code in a JTextPane.
When I set the content type to "text/plain", the JTextPane change from multiline to singleline and all code is displayed only in the first line.
How can i change my code to show the HTML source in a multiline JTextPane ?
What is your purpose in messing with HTMLEditorKit? HTMLEditorKit is intended to be used with JEditorPane and is (unless I'm missing something) pointless to use with JTextPane.
The same thing goes for setContentType(). JTextPane inherits that method from JEditorPane, but calling JTextPane.setContentType() pretty much always a mistake.
If you want a plain JTextPane, then simply instantiate one using the zero-argument constructor. (Or use JTextArea if you want something even simpler.) If you want to use HTMLEditorKit (which would be more appropriate for rendering HTML than for displaying HTML source) then use JEditorPane.