Results 1 to 4 of 4
Thread: Image Observer class
- 06-10-2012, 02:19 AM #1Member
- Join Date
- May 2012
- Rep Power
Image Observer class
Hey guys, I'm writing a code in the Java IDE Ready to Program, (for those of you who don't know its the IDE by Holtsoft, they're out of business now, but I need to use it). In my code I'm inputting several different images, and i need each image to be called upon several times. And when I run my program it works fine, the pictures appear, but when i try to call upon the image more than once it simply doesn't show up. Anyways, here is a simplified version of my program (just the image call and loop).
// The "Help" class.
public class Help
static Console c; // The output console
static Image theGraphic;
public static void main (String args)
c = new Console ();
while (2 > 1); //create an infinite loop, for testing puropses
} // main method
private static void theGraphic ()
Toolkit tk = Toolkit.getDefaultToolkit ();
theGraphic = tk.getImage ("image location");
tk.prepareImage (theGraphic, -1, -1, new Observer1 ());
}//prepare the image
static class Observer1 implements ImageObserver
public boolean imageUpdate (Image img, int infoflags, int x, int y, int width, int height)
c.drawImage (img, 0, 0, null);
}//draw the image
} // Help class
if any one can tell me how to make it work the way i need it to work I would greatly appreciate it.
- 06-10-2012, 06:08 AM #2
- 06-10-2012, 06:12 AM #3
Re: Image Observer class
Since not many (if any) members will be familiar with the hsa.Console class, you may have a long wait for help with that code. However, I'll give you this: Toolkit caches an image obtained from a specific location and doesn't reload the image from the same location on demand. One way to force a reload is to flush() the Image.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 06-10-2012, 06:13 AM #4
- By chyrl in forum Advanced JavaReplies: 5Last Post: 01-14-2011, 05:41 PM
- By brontolo in forum Advanced JavaReplies: 6Last Post: 09-02-2010, 03:40 PM
- By livnihai in forum New To JavaReplies: 5Last Post: 10-11-2009, 03:34 PM