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
Try
Color otherColor = new Color(someInt);
and then
if (otherColor.equals(robot.getPixelColor(someX, someY))
{
...
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.