This is not an applet, and I'm not displaying the image for the user, either. I've got an image (my oCanvas object is a Graphics2D) that I'm drawing by calling drawString and fillRect to put stuff on it, and then I'm writing it out to a file. I've been using this for a long time and am trying to simply modify it by calling drawImage on it. I have a local image file that I want to add to this image, and here's the code that's not working:
The class I'm in extends Component, which is why I have this in there, but I also tried it by overriding the imageUpdate method, and I've also tried it with null in there. drawImage is returning false, meaning the image is not yet loaded. I need my program to wait for that image to be drawn before going on, and I've been Googling around for a while trying to figure out a good way to do this, b/c I'm finding wading around this particular section of the API to be a bit hairy for me (being that I rarely do anything with graphics). Thanks for any help!
The MediaTracker class lets you easily download data for a group of images and find out when the images are fully loaded. Ordinarily, an image's data isn't downloaded until the image is drawn for the first time. To request that the data for a group of images be preloaded asynchronously, you can use the forms of checkID() and checkAll() that take a boolean argument, setting the argument to true. To load data synchronously (waiting for the data to arrive), use the waitForID() and waitForAll() methods. The MediaTracker methods that load data use several background threads to download the data, resulting in increased speed. To check on the status of image loading, you can use the MediaTracker statusID() and statusAll() methods. To simply check whether any image data remains to be loaded, you can use the checkID() and checkAll() methods.