• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't render image!  RSS feed

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

Actually i was looking at creating executable jar and through FAQ (Java Beginner) i got this topic.

I have copied the below classes from the above mentioned topic.

Foo.java



ImagePanel.java



When i try to run the Foo.java, i am getting following error.



FYI : It is able to find the image and create its object also.


Can someone help me about this?
Thanks.
[ May 27, 2008: Message edited by: Vishal Pandya ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is able to find the image and create its object also.

How can that be possible if the connection to retrieve the image throws an exception?
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:

How can that be possible if the connection to retrieve the image throws an exception?

Hello Ulf,

Initially i also thought the same then,
I added below piece of into ImagePanel.java



And the following is the output.



Please note Image object isn't null in output.

Where should i look into?

Thanks.
[ May 27, 2008: Message edited by: Vishal Pandya ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fact that the Image object is not null does not mean that the image data is available. You need to use a java.awt.MediaTracker object to track the progress of the image download, and only when the tracker tells you that it has been loaded should you use the Image object.

The javadocs of MediaTracker have an example of how this works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!