-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
hopper
-
sparc
-
solaris_2.5.1
Name: mf23781 Date: 06/11/98
We received the following Swing defect from one
of our customers.
If you make a toolbar with animated gifs as the
rollover icons in swing, after rolling over every
icon, the CPU spins when nothing should be
happening. It seems as though once you view an
animated gif, it keeps on animating even when it
is not being displayed.
Investigation showed that the problem is a general
Swing problem. It occurs on AIX and Solaris, and
we expect it to on NT as well.
The JButton class is an ImageObserver, but it doesn't
indicate whether or not the image is showing, so it
gets continuously animated, even when it is not visible.
The way to get it to indicate this is to override the
imageUpdate() method, and return true or false
appropriately (as hinted to in the evaluation of Sun
bug 4073923).
We added this method to JButton.java:
public boolean imageUpdate(Image img,int infoflags,
int x,int y,int width,int height)
{
super.imageUpdate(img,infoflags,x,y,width,height);
ButtonModel model = this.getModel();
return this.isRolloverEnabled() && model.isRollover();
}
This fixes the problem in the case of setting an animated GIF
to be the rollover icon.
A more complete solution would be required to prevent the
problem occurring if animated GIFs are used for the other
states of the buttons.
======================================================================
- relates to
-
JDK-4302818 Animated GIF eats CPU when not visible
-
- Resolved
-