This topic is 5020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

sometimes (actually almost every seccond time) I do not get the image width and height when I use sun's getImage()?? anyone had the same problem before? any god solution for this, or is it best to write my own image loader?

Share on other sites
Do you use Toolkit.getDesfultToolkit().getImage(String)? if so you should also have a MediaTracker that keeps track if the image has been loaded or not.

try{MediaTracker track=new MediaTracker(myComponent);track.addImage(1,myImage);track.waitForAll();} catch (InterruptedException e) {}

Share on other sites
yes, I do.. but it is still something corky going on.. :)

Share on other sites
Could we see some code please :)

Share on other sites
If you can, use ImageIO.read(getClass().getResource("/yourimage.jpg")) to load images without requiring a MediaTracker. The only constraint here is that for an applet, you might have to put the images in the same JAR file as the code (I'm not sure if I recall this correctly though).

• 10
• 17
• 9
• 13
• 41