Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Detect loading of ImageIcon from URL?

 
Barclay Berger
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As is explained here, you should first verify that the URL is valid. Additionally/alternatively you can provide an image observer to get more information about the loading process via the ImageIcon.setImageObserver method.
 
Barclay Berger
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll try the url stuff first, other is above my head
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!