Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8261018

Graphics.setColor(null) is not documented

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • client-libs
    • None
    • 2d
    • behavioral
    • minimal
    • Java API
    • SE

      Summary

      It is not documented what Grahics.setColor(null) should do. According to the implementation Graphics.setColor(null) does not change graphics color at all.

      Problem

      It is not documented what Grahics.setColor(null) should do.

      Solution

      Document Graphics.setColor(null) citing it is silently ignored, same way Graphics.setFont(null) is documented.

      Specification

      diff --git a/src/java.desktop/share/classes/java/awt/Graphics.java b/src/java.desktop/share/classes/java/awt/Graphics.java
      index fe8437f029e..234b474764e 100644
      --- a/src/java.desktop/share/classes/java/awt/Graphics.java
      +++ b/src/java.desktop/share/classes/java/awt/Graphics.java
      @@ -193,6 +193,7 @@ public abstract class Graphics {
            * Sets this graphics context's current color to the specified
            * color. All subsequent graphics operations using this graphics
            * context use this specified color.
      +     * A null argument is silently ignored.
            * @param     c   the new rendering color.
            * @see       java.awt.Color
            * @see       java.awt.Graphics#getColor
            */
           public abstract void setColor(Color c);

            psadhukhan Prasanta Sadhukhan
            idk Igor Kushnirskiy (Inactive)
            Sergey Bylokhov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: