JEditorPane shows IMG tags broken when image file is in application's jar

M

Mark H. Wood

I'm trying to add some built-in documentation to my application. I'm
using a JEditorPane (also tried JTextPane) to display HTML documents.
The documents are packed in the jar with the application's classes.

The base document displays just fine, and I can link to other HTML
documents without trouble, but IMG tags always display as a
broken-image icon. I can't find anything to say that I should not be
able to refer to images in a jar from HTML documents in a jar, and
images used for other purposes work well. Clues would be welcomed.
 
V

VisionSet

Mark H. Wood said:
I'm trying to add some built-in documentation to my application. I'm
using a JEditorPane (also tried JTextPane) to display HTML documents.
The documents are packed in the jar with the application's classes.

The base document displays just fine, and I can link to other HTML
documents without trouble, but IMG tags always display as a
broken-image icon. I can't find anything to say that I should not be
able to refer to images in a jar from HTML documents in a jar, and
images used for other purposes work well. Clues would be welcomed.

Try this:

<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/plaf/basic/BasicHTML.ht
ml#documentBaseKey>

Let us know if it works.
 
A

Andrew Thompson

The base document displays just fine, and I can link to other HTML
documents without trouble, but IMG tags always display as a
broken-image icon. I can't find anything to say that I should not be
able to refer to images in a jar from HTML documents in a jar, and
images used for other purposes work well.

'Mike W' addressed your immediate question,
I just thought I would confirm that the I
have seen the JEditorPanes load images
referenced in HTML that are inside jar files.

You just need to get that 'base' correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top