> I'm developing an application which can let user to open and modify the HTML
> document within the class extended JInternalFrame. But I experienced a
> problem when closing the subclass of JInternalFrame. The code for saving the
> modificatino of the content is in follow:
How is JInternalFrame relevant to the problem?
> public DocumentReader(HTMLEditorKit kit, HTMLDocument doc, String path)
> throws IOException{
Use File, not String, for representing filenames.
> this.kit = kit;
> this.doc = doc;
> this.path = path;
> this.writer = new FileWriter(new File(this.path));
> this.htmlWriter = new HTMLWriter(this.writer, this.doc);
You are not using HTMLWriter anywhere.
> }
>
[quoted text clipped - 18 lines]
> at javax.swing.text.html.HTMLEditorKit.write(HTMLEditorKit.java:290)
> at
Please post Java version together with stack trace or the line numbers
are useless.
The problem is that 'null' is passed to AbstractWriter.write(String)
(which fails silently in 1.4.2 - since when?) - just override it to
ignore it?
Somewhat guessing, I would say this happens because the Document has
a title element, but its TitleProperty is 'null'.
Christian
Plutian - 27 Jan 2004 01:48 GMT
> Somewhat guessing, I would say this happens because the Document has
> a title element, but its TitleProperty is 'null'.
>
> Christian
Hi Christian,
Thx a lot, I think your guessing is correct. I viewed the source code
of the HTMLWriter and found that the NullPointerException is occurred
when getting the TitleProperty of the Document. So is it normal? and
the only way is to overwrite the Writer and ignore the null??
Thx,
Plutian
Christian Kaufhold - 27 Jan 2004 12:59 GMT
Hello!
>> Somewhat guessing, I would say this happens because the Document has
>> a title element, but its TitleProperty is 'null'.
> Thx a lot, I think your guessing is correct. I viewed the source code
> of the HTMLWriter and found that the NullPointerException is occurred
> when getting the TitleProperty of the Document. So is it normal? and
> the only way is to overwrite the Writer and ignore the null??
It seems to happen if either
a) the Document contained an empty title element on reading
(<TITLE>/<TITLE)
b) the Document originally did not contain a title element and it is
added later without also updating the title property.
c) the title property is unset.
The only way to fix it is to change the writer. (But also the reader not
to produce it that way). It depends on your taste whether the writer
should offically handle this or whether the client of the HTMLDocument
is responsible for not putting it into this state.
Christian
Plutian - 27 Jan 2004 15:35 GMT
Thx a lot!!!!! It's very useful and the problem is solved!!!
"Christian Kaufhold" <usenet@chka.de>
???????:0t40165fdei586bn1f4@simia.chka.de...
> Hello!
>
[quoted text clipped - 19 lines]
>
> Christian
"Plutian" ...
Tips when seeking help..
a) http://www.physci.org/codes/sscce.jsp
b) Ask a question.
--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site