Results 1 to 2 of 2
  1. #1
    barkster is offline Member
    Join Date
    Jan 2008
    Posts
    2
    Rep Power
    0

    Default Detect loading of ImageIcon from URL?

    I'm pretty new to java, I'm trying to detect if an image gets loaded or not, don't know how to do that. I thought by catching the url command it would do it but if you link to an image that doesn't exist it doesn't throw and exception. How can I either detect if url was correct or if icon exists? Thanks

    Java Code:
               
    java.net.URL where = new URL("http://www.domain.com/testimage.jpg");
    ImageIcon icon = new ImageIcon(where);

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    ImageIcon doesn't tell you if an image file could not be found or if image data is corrupt or unreadable. It does have a method getImageLoadStatus which you can use to investigate loading problems/success. ImageIO.read methods throw exceptions.

Similar Threads

  1. Replies: 0
    Last Post: 01-20-2008, 06:07 AM
  2. Loading An Image Help Please!
    By shaungoater in forum Java 2D
    Replies: 2
    Last Post: 01-09-2008, 08:14 AM
  3. copy image/imageicon into a file on disk
    By archanajathan in forum Advanced Java
    Replies: 2
    Last Post: 11-22-2007, 06:21 AM
  4. Help Loading Up Pictures
    By marco in forum Java Applets
    Replies: 3
    Last Post: 08-14-2007, 10:32 PM
  5. Detect TimeOut in a HttpURL Connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •