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

java.awt.Color.equals() does not work when comparing to java.awt.SystemColor

XMLWordPrintable

    • b02
    • x86
    • windows_2000
    • Verified

      Name: gm110360 Date: 12/07/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      When you compare two colors for equality using equals( Object obj ) the test
      will likely fail if one of the colors is java.awt.Color and one is
      java.awt.SystemColor. Because SystemColor extends Color, you might think equals
      would work. Here is the code from Color:

      public boolean equals(Object obj) {
          return obj instanceof Color && ((Color)obj).value == this.value;
      }

      The problem is that value is the rgb value in Color. In SystemColor value is
      the index to the color table in systemColors.
      (Review ID: 134033)
      ======================================================================

            dav Andrei Dmitriev (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: