Who can tell me the "proper" way of loading an image from the web and displaying it in a component?
I (am trying to) write a component that displays (some) HTML and need images (please don't tell me there are JavaBeans for displaying HTML - it's really hard to find a JavaBean for JDK 1.02 *g* *sigh*). I only need basic functionality for certain pages (under my control).
The component is derived from a Panel (display area + scrollbar(s)). I use theApplet.getImage(...) to get the image and "offscreenGraphics.drawImage(img,x,y,width,height,theApplet)" to display it (sorry, don't have the exact code here, but it would really help if I had some answer before Monday morning...
The code is "kind of" correct, but I seem to have a problem with the "asynchronous retrieval". The first time I try to display an image, it doesn't show, the second (and subsequent) times (for the same image), it works fine.
The help file says: getImage returns an image object immediately, even if the image is not yet available. The image is retrieved as soon as it is needed. Well, this doesn't seem to work.
What exactly is the role of the "imageObserver" that is passed as a parameter. What does it need to do?? I currently only pass the applet (which worked before). Right now, I use a rather simply method for layout and it would be great if I could have the image available at a known time instead of havin to respond to something like an "imageComplete"-event (i.e. save the positions of all images).
I'll increase the points for good answers that do not only solve the problem but also tell me WHY it doesn't work right now. I could probably find a workaround myself, but that's NOT what I'm looking for - the code needs to be 100% reliable!
Thanks for your help! :-))