Determining whether painting entire component within paint function

Hi All,

I have a scenario where I need to perform some functionality only when paint method of a component is invoked because of repaint(x,y,width,height). If the paint method is invoked because of repaint()(reapinting the entire component), then I dont want to perform that functionality.


Is there a way to find within the paint method whether it is invoked just to repaint the subsection of the component or the entire component itself??


Best Regards,


Uh well I think you could use Graphics::getClipBounds() and compare its size to your component's getLocalBounds() - if they match, the whole component is being repainted. But it seems like a pretty dodgy thing to do - it sounds like you're mixing your logic with your view too much. Why do you need to do it? If it's to avoid doing expensive recalculations when you're only painting part of the component, I suggest you do the calculations in resized() and cache the results.

+1 to that sounding dodgy!

Whatever it is that you're actually trying to achieve, I can tell you from many years of experience that checking repaint regions is not the right way to do it!