Click to See Complete Forum and Search --> : HTML displayed in a JTextPane


Dave Simpson
April 5th, 1999, 03:04 PM
I'm trying to display an HTML, read in from a local file, in a JTextPane.
I'm trying not to use a file URL. In the following code, everything works
except I get a NullPointerException in the last line. I think the problem is
that the HTML is not being parsed properly. The file looks like this :

<HTML>
This is a test.
</HTML>

(In my application)
HTMLEditorKit htmlEditor = new HTMLEditorKit();

FileInputStream htmlStream = new FileInputStream ("test.html");

JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setEditorKit(htmlEditor);

htmlEditor.read(htmlStream, textPane.getDocument(),3);