jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes cant display gif/jpeg in JEditorPane ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "cant display gif/jpeg in JEditorPane ?" Watch "cant display gif/jpeg in JEditorPane ?" New topic
Author

cant display gif/jpeg in JEditorPane ?

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
Can someone please tell me how to do this ?
I am using jdk1.4 using full directory path
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
thanks
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I figured it out... the IMG tag can only take the URL of the image... you are giving it a path to the image... here's an example of what to do :



I did find one problem with this though... if you are on a windows system and the file is in any directory or subdirectory that has a space in the name, the generated URL doesn't work... you'd probably have to parse the URL and change all spaces to %20 or something...


-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: cant display gif/jpeg in JEditorPane ?
 
Similar Threads
img tag in jsp
JEditorPane problem displaying non-English text in 1.4 (Linux)
logic:forward problem
how to include image in JEditorPane ?
Image not displayed in the browser