File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes how to include image in JEditorPane ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to include image in JEditorPane ?" Watch "how to include image in JEditorPane ?" New topic
Author

how to include image in JEditorPane ?

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
1. i am trying to display a .png image, will that
work or will only .gif work ?
2.
I am using following code
----------------------------------------
String text = "<html>\n" + "<font color=red>hi my name is sarim</font>\n" + "<img src=\"/home/masters/2001/sr1305/tomcat/webapps/ROOT/myadmin/graphs/copy.gif\" width=200 height=200></img>";
editorPane = new JEditorPane(type, text);
it shows the font, but shows an empty icon in place of the image....
I have included the full absolute path to the image folder

Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You'll have to use the add-on JAI (Java Advanced Imaging) API, or the new (JDK 1.4+) ImageIO classes to open and display a PNG image... the pre-1.4 JDKs only supported GIF and JPG images "out of the box".

Ohh... just looked at the #2 part of your question... I'm not sure if the JEditorPane HTMLEditorKit would be able to support PNG if it was able to find the JAI PNG loaders or not... maybe it will... if not you'll have to write a new HTML editor kit to support PNGs once you are able to load them...
[ August 15, 2002: Message edited by: Nathan Pruett ]

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to include image in JEditorPane ?
 
Similar Threads
cant display gif/jpeg in JEditorPane ?
JEditorPane problem displaying non-English text in 1.4 (Linux)
help for shopping cart
Aligning HTML text/images in JEditorPane
How to check if textboxes are null