views:

483

answers:

2

I have an editor pane which displays an HTML file. When I ask it to do it once, it displays the HTML file fine. I then make changes to my HTML file and use the setPage method so that it prints the updated HTML file but it doesn't do this even though the HTML file is changed.

Is this a problem with the Editor pane or is there something wrong with my code?

A: 

I've done some tests and I've reproduced this behaviour. When I am calling setPage and passing as argument the same URL that was passed previously in the same method, the JEditorPane seems to ignore the call.

A simple work around: test if the new Url is the same as the previous one. If yes, format the Url a bit differently. For example add an %20 at the end. The new Url actually refers to the same page, but the JEditorPane will consider it as a new one and it will properly reload it.

kgiannakakis
+3  A: 

Looking at the JavaDoc for setPage, I see the following:

If the desired URL is the one currently being displayed, the document will not be reloaded. To force a document reload it is necessary to clear the stream description property of the document. The following code shows how this can be done:

Document doc = jEditorPane.getDocument();
doc.putProperty(Document.StreamDescriptionProperty, null);
Eddie