Graphics.dispose
Class Overview | Class Members | This Package | All Packages
Syntax
public abstract void dispose()
Description
Disposes of this graphics context and releases any system resources that it is using. A Graphics object cannot be used after disposehas been called.
When a Java program runs, a large number of Graphics objects can be created within a short time frame. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.
Graphics objects which are provided as arguments to the paint and update methods of components are automatically released by the system when those methods return. For efficiency, programmers should call dispose when finished using a Graphics object only if it was created directly from a component or another Graphics object.