JDK-7000091 : Methods java.awt.Color.darker/brighter() say nothing about changing alpha component
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2010-11-15
  • Updated: 2012-03-22
  • Resolved: 2010-11-16
Related Reports
Duplicate :  
Description
quoting originally filed 6784594:
----------------------------------------------------------------------------
http://download.oracle.com/javase/6/docs/api/java/awt/Color.html#brighter()
http://download.oracle.com/javase/6/docs/api/java/awt/Color.html#darker()

Java SE specification states for java.awt.Color.brighter()/darker() methods:

For instance "darker"
  "This method applies an arbitrary scale factor to each of the three RGB 
   components of this Color to create a darker version of this Color."

This means that alpha component must remain unchanged, however it is not
the case for many Java implementations: 1.4.2, 5.0, 6.0, 7.
----------------------------------------------------------------------------

The following code illustrates that alpha is being reset to 255.


import java.awt.*;

public class ColorBrighterDarker {
    
    public static void main(String[] args) {
        System.out.println(new Color(123, 123, 123, 123).brighter().getAlpha());
        System.out.println(new Color(123, 123, 123, 123).darker().getAlpha());
    }

}
----------------------------------------------------------------

The output will be

255
255