Skip to main content

Can't display image in JEditorPane + HTML

6 replies [Last post]
sergio_m
Offline
Joined: 2007-08-30

Hello.
Isn't possible to display an image in JEditorPane setting the following HTML?
A .html page in a browser works fine but in JEditorPane not!
Do you know the reason? Thanks in advance.

Where's the Image?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sergio_m
Offline
Joined: 2007-08-30

just to read better the code, substitute '#' with '<'

#html> #head> #/head> #body> #table border='1' width='100%'>
#tr> #td>
where is the Image?
#tr>
#td> img src="c:\sad.bmp">
#/td>
#/tr>
#/table> #/body> #/html>

rah003
Offline
Joined: 2004-05-26

src attribute is supposed to contain url not a file path. If your url is pointing to a local filesystem, you have to say so. Try
[code]

[/code]

sergio_m
Offline
Joined: 2007-08-30

Thanks rah003... but it doesn't work. The very strange thing is that the same HTML code, as a separate .html file, works in a browser!
So I am supposing the JEditorPane accepts HTML code but the image contents.
Any Help?
Thank you.

rah003
Offline
Joined: 2004-05-26

> Any Help?

Yeah, don't use bitmaps, but jpg, gif or png as an image. While IE can render bmp, it is not mandatory for browser/html parser to be able to show those.

dpaez85
Offline
Joined: 2011-07-08

Hi, I am trying to display and html page that contains a png image in JEditorPane and I don't get the image. This is waht I am doing:

java.net.URL helpURL = ClassLoader.getSystemResource("ChartReport.html");
myEditorPane.setPage(helpURL);

******ChartReport.html********

<body class="style_0" style=" margin:0px;">
<table cellpadding="0" rule="none" style="empty-cells: show; width:8in; overflow: hidden; table-layout:fixed;">
<col></col>
<tr>
<td></td>
</tr>
<tr>
<td valign="top">
<div>
<img src="images/previewCA91LA3F.png" alt="" />
</div>
</td>
</tr>
<tr>
<td>
<div>Jul 8, 2011 10:16 AM</div>
</td>
</tr>
</table>
</body>

Thanks in advanced

sergio_m
Offline
Joined: 2007-08-30

Very good! It runs.
Thank you very much.