Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: HTML in JOptionPane

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Default HTML in JOptionPane

    I need to display an image in a JOptionPane. The image is in the project src folder together with the .java source files.

    The html code seems to be good as an image placeholder is shown in the JOptionPane when the program is run. The problem appears to be regarding the image path.

    The html code i am using is:

    <html><body><img src="imagename" /></body></html>

    What file path should I give to display an image present in the src folder?

    Last edited by LordThumper; April 23rd, 2011 at 07:07 AM.

  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Faversham, Kent, UK
    My Mood
    Thanked 58 Times in 54 Posts

    Default Re: HTML in JOptionPane

    Images normally go in the same package as the application - in the package root, or an image subdirectory below that.
    Have you tried providing an absolute path or a relative path from the package root ?

Similar Threads

  1. Using Icons in JOptionPane
    By Jchang504 in forum AWT / Java Swing
    Replies: 3
    Last Post: September 19th, 2014, 02:28 PM
  2. JOptionPane problem
    By frozen java in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 7th, 2011, 06:16 PM
  3. Convert to JOptionPane
    By ahzim8 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2011, 08:52 AM
  4. Change to JOptionPane
    By Liuric in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 1st, 2010, 12:07 AM
  5. JOptionPane using If and Else
    By Liuric in forum Member Introductions
    Replies: 7
    Last Post: October 1st, 2010, 12:05 AM