1

I'm trying to display an image in a JEditorPane in a Java Swing window. The user uses a JFileChooser to find the absolute path of an image on their computer, and then that absolute path is embedded into an HTML <img> tag, which is then set in a JEditorPane. For some reason, the image will just not show in the JEditorPane, and I can't figure out why. I've Googled around and found various solutions, but none have worked. Can someone please help me?

Mike Rinehart
  • 445
  • 2
  • 6
  • 17
  • 1
    1) See [this answer](http://stackoverflow.com/a/6373907/418556) for general tips. 2) I suspect the code is using a string representing a `File` for the image path, when an `URL` should be used. 3) For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Nov 04 '12 at 07:15

1 Answers1

2

You can place the images in the imageCache of Document like it's described here http://java-sl.com/tip_local_images.html

StanislavL
  • 56,971
  • 9
  • 68
  • 98