views:

19

answers:

0

The Situation

I have an application that renders a colour gradiant into a Jpanel via overriding the paintComponent method. The algorithm is setup so that when the window is resized it recreates the colour gradient to refill the JFrame's new dimensions.

Even though the calculation for the gradient values only takes 10 - 30 ms (depending on the size of the Jframe) if one manually resizes the window by clicking & dragging, the paintComponent method is only being called by the reSize event at a frequency of around 3Hz (1/3 of a second or so). The result is that if one resizes the window rapidly the JPanel redraws in a series of steps appprox. ~300ms apart.

Now I assume that within the underlying mechanism of Java's component resizing there is a 'resize listener' that places a repaint event into EDT to instruct the resized component to call its own paintComponet method.

The Question

Is there some way I can control the frequency at which the resize listener 'triggers' when the user is resizing a window? Ideally can the listener 'polling frequency' be dropped to 25Hz (40ms) to trigger repaints rapidly enough to achieve a smooth change of the gradient within the JPanel.