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 code snippet helps to reproduce the problem:
-------------------------------------------------
import java.awt.Color;
public class TestColor {
private void test(boolean direction) {
Color color = new Color(20, 20, 20, 125);
System.out.println(color.getAlpha());
final int initialAlpha = color.getAlpha();
for (int i = 0; i < 3; i++) {
if (direction) {
color = color.brighter();
} else {
color = color.darker();
}
if (color.getAlpha() != initialAlpha) {
System.out.println(direction ? "Color.brighter() failed: " + color.getAlpha() + " " + initialAlpha :
"Color.darker() failed: " + color.getAlpha() + " " + initialAlpha);
}
}
}
public static void main(String argv[]) {
new TestColor().test(true);
new TestColor().test(false);
}
}
--------------------------------------------------------------