AWT Components as Image Observers

As alluded to earlier, when an AWT component is specified as an image observer, java.awt.Component.imageUpdate() is invoked by the image's image producer—provided, of course, that the method has not been overridden in a subclass. None of the components provided by the AWT overrides imageUpdate(); all exhibit the behavior of Component.imageUpdate(), which is listed in Example 5-10.

Example 5-10. java.awt.Component.imageUpdate()
 public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) { int rate = -1; if ((flags & (FRAMEBITS|ALLBITS)) != 0) { rate = 0; } else if ((flags & SOMEBITS) != 0) { if (isInc) { try { rate = incRate; if (rate < 0) rate = 0; } catch (Exception e) { rate = 100; } } } if ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.