Trouble with displaying multiple images in web applet
Posted on 2003-02-26
I've been stuck on a problem for days now and just can't seem to find the solution to my problem. I'm sure it's something simple I'm overlooking. If anyone can point me in the right direction here I would be most appreciative.
I have a web based java applet that displays two windows of very small images. One window contains 48 images averaging 15x15 while the second window contains something a bit over 100 images ranging up to 110x50 -- The image sources are all defined in an SQL database on the server side and fed into the applet after startup via a tcp/ip socket.
in a nutshell:
If I slow down the loading of the images to about 1 per second or two, then I can load all of the images and display them without a problem. However, if I remove that speed restriction and let the applet rip, the first 20 or so will load almost instantly and then they start "popping in" in somewhat random intervals. About half of the images will, simply, never load no matter how long you wait.
I am assuming the problem is related to too many threads or sockets running. However, there are no exceptions being thrown and no "problems" I can identify in the Image instance or getImage() call itself -- that is: getImage() is returning a non-null Image instance and it appears to be fine except that it will not paint.
Is anyone familiar with this probelm? If so: how can I detect the problem has occured (programmatically -- it's pretty obvious visually ~smile~) in order to refetch the image or, better still, prevent the problem in the first place without having to wait two or three seconds for every image to load before loading the next one?
public class fubar extends Panel implements ImageObserver
// constructor blah blah blah
public void paint( Graphics g )
// this call will never draw anything on the "broken" images
g.drawImage( image, 0, 0, this );
public imageUpdate( Image img, int flags, int x, int, y, inw w, int h )
// this code is never called for about half the images
System.err.println( "we're in the update func" );