Graphics
object cannot be used after dispose
has 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.
@see java.awt.Graphics#finalize
@see java.awt.Component#paint
@see java.awt.Component#update
@see java.awt.Component#getGraphics
@see java.awt.Graphics#create
|
|
|
|
|
|
|
|
|
|
|
|