Optimizing paint() in JScrollPane's viewport
Hi
I'm developing a graphic app. I added a JPanel to a JScrollPane. I did some drawing in the JPanel. Everytime when I scroll, JScrollPane would call the paint() method in the JPanel. I would like to optimize the drawing. Only paint when the scrolling has stopped.
What I am currently doing is to install a custom BoundedRangeModel to JScrollPane's horizontal and vertical JScrollBar. I override the setValueIsAdjusting() method. Then this method is invoked, I would examine the boolean value. If both of these are false, then I would perform a repaint.
Is there a more elegant way of doing this?
Thanks
Regards
Chuk

