< prev index next >

src/java.desktop/share/classes/java/awt/Graphics.java

Print this page

1145      * may not run to completion for a long period of time.
1146      * <p>
1147      * Graphics objects which are provided as arguments to the
1148      * {@code paint} and {@code update} methods
1149      * of components are automatically released by the system when
1150      * those methods return. For efficiency, programmers should
1151      * call {@code dispose} when finished using
1152      * a {@code Graphics} object only if it was created
1153      * directly from a component or another {@code Graphics} object.
1154      * @see         java.awt.Graphics#finalize
1155      * @see         java.awt.Component#paint
1156      * @see         java.awt.Component#update
1157      * @see         java.awt.Component#getGraphics
1158      * @see         java.awt.Graphics#create
1159      */
1160     public abstract void dispose();
1161 
1162     /**
1163      * Disposes of this graphics context once it is no longer referenced.
1164      *
1165      * @deprecated The {@code finalize} method has been deprecated.
1166      *     Subclasses that override {@code finalize} in order to perform cleanup
1167      *     should be modified to use alternative cleanup mechanisms and
1168      *     to remove the overriding {@code finalize} method.
1169      *     When overriding the {@code finalize} method, its implementation must explicitly
1170      *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
1171      *     See the specification for {@link Object#finalize()} for further
1172      *     information about migration options.
1173      * @see #dispose
1174      */
1175     @Deprecated(since="9")

1176     public void finalize() {
1177         dispose();
1178     }
1179 
1180     /**
1181      * Returns a {@code String} object representing this
1182      *                        {@code Graphics} object's value.
1183      * @return       a string representation of this graphics context.
1184      */
1185     public String toString() {
1186         return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]";
1187     }
1188 
1189     /**
1190      * Returns the bounding rectangle of the current clipping area.
1191      * @return      the bounding rectangle of the current clipping area
1192      *              or {@code null} if no clip is set.
1193      * @deprecated As of JDK version 1.1,
1194      * replaced by {@code getClipBounds()}.
1195      */

1145      * may not run to completion for a long period of time.
1146      * <p>
1147      * Graphics objects which are provided as arguments to the
1148      * {@code paint} and {@code update} methods
1149      * of components are automatically released by the system when
1150      * those methods return. For efficiency, programmers should
1151      * call {@code dispose} when finished using
1152      * a {@code Graphics} object only if it was created
1153      * directly from a component or another {@code Graphics} object.
1154      * @see         java.awt.Graphics#finalize
1155      * @see         java.awt.Component#paint
1156      * @see         java.awt.Component#update
1157      * @see         java.awt.Component#getGraphics
1158      * @see         java.awt.Graphics#create
1159      */
1160     public abstract void dispose();
1161 
1162     /**
1163      * Disposes of this graphics context once it is no longer referenced.
1164      *
1165      * @deprecated Finalization has been deprecated for removal.  See
1166      * {@link java.lang.Object#finalize} for background information and details
1167      * about migration options.
1168      * 




1169      * @see #dispose
1170      */
1171     @Deprecated(since="9", forRemoval=true)
1172     @SuppressWarnings("removal")
1173     public void finalize() {
1174         dispose();
1175     }
1176 
1177     /**
1178      * Returns a {@code String} object representing this
1179      *                        {@code Graphics} object's value.
1180      * @return       a string representation of this graphics context.
1181      */
1182     public String toString() {
1183         return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]";
1184     }
1185 
1186     /**
1187      * Returns the bounding rectangle of the current clipping area.
1188      * @return      the bounding rectangle of the current clipping area
1189      *              or {@code null} if no clip is set.
1190      * @deprecated As of JDK version 1.1,
1191      * replaced by {@code getClipBounds()}.
1192      */
< prev index next >