Use the getRGB() method for comparing colors in Java
Description
The following code shows how to use the getRGB() method for comparing colors.
Example
/*from ww w. j av a2 s . c o m*/
import java.awt.Color;
public class Main {
public static void main(String[] a) {
Color myBlack = new Color(0, 0, 0); // Color black
Color myWhite = new Color(255, 255, 255); // Color white
System.out.println(myBlack.getRGB() == myWhite.getRGB());
System.out.println(myBlack.getRGB());
System.out.println(myWhite.getRGB());
}
}