How do you know when you are supposed to call dispose() on a Graphics object? I’ve seen code in examples, even in Sun’s tutorials, where I’ve expected that dispose() should be called but it isn’t. In the same way I’ve seen code call dispose() when I didn’t think it was needed.
E.g. in your paint(Graphics g) method you would typically not call dispose on the Graphics passed in, right?
But if you get the Graphics object for a buffered image you should call dispose() when you are done drawing to it, right?
Can somebody clarify exactly when it is needed, and when it isn’t? And what harm it might do to call it when not needed, or not call it when needed.