File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant display gif/jpeg in JEditorPane ?

 
sarim raza
Ranch Hand
Posts: 232
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic