I am Java beginner and I am trying to code something. Currently I am stucked at getPixelColor(). It开发者_开发技巧's the method of class Robot. I can get pixel color but don't know how to compare with other color. Let's say that my other color is stored in some int variable and I need to compare these two colors. But I can't compare these two colors, because it throws this error "incomparable types:int and java.awt.Color". So how convert it to int?
Thanks
Probably something like:
if(color.getRGB() == stored_color){
}
Anyways, you need to access the Color object's getRGB function to compare the numeric value to another int.
Try
Color otherColor = new Color(someInt);
and then
if (otherColor.equals(robot.getPixelColor(someX, someY))
{
...
}
精彩评论