This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes imageIcon 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 "imageIcon" Watch "imageIcon" New topic


Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
Now I've got another problem. I'm trying to make an imageIcon and add it to my content pane but it doesn't show up in my applet, theres a blank space where it should be. Is there something wrong with my code?

Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
  • Is there a reason you are using backslashes in the URL?
  • You intend to pass a URL to the ImageIcon constructor but you are actually passing in a String, which (according to the javadoc) will be interpreted as a file name. You may want to try new ImageIcon(new URL("http://blah...
  • Are you sure there is an image at that URL? If it can't find the image you you specify, it will silently behave as you describe. You may want to try an absolute pathname to an image on your local machine as a test.

  • bitguru blog
    I agree. Here's the link:
    subject: imageIcon
    Similar Threads
    ImageIcon not working
    Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
    Swing: Using icon resources in a jar
    how to add images dynamically to jpanel?
    problem in setting background image of jpanel