0

NOTE: robot.getcolor(int i, int j) is simply return robot.getPixelColor(i,j);

void test2(int i, int j)
{
    System.out.println(robot.getcolor(i,j));
    Color a = robot.getcolor(i,j);
    Color b  = new Color(91,108,201);
    if(a == b)
    {
        System.out.println("success!");
    }
    else
    {
        System.out.println("FAILURE");
    }
}

If I do that, then I get this outprint:

java.awt.Color[r=91,g=108,b=201]

FAILURE

What I already tested:

  • Comparing two colors with == works.

  • The Alpha parameter shouldn't be a problem, since its 255 and if I add it into the new Color(91,108,201,255) it still prints out FAILURE.

luator
  • 4,769
  • 3
  • 30
  • 51

1 Answers1

3

Try changing line 6 to something like if(a.equals(b)) {.

== compares if two objects are the same object
.equals() compares if two objects are equivalent (as defined by that specific class)
Check out this for more info

beartech1
  • 149
  • 1
  • 1
  • 10