I am not sure why my if statement isn't working. I am trying to activate a function when the background of a certain JButton is black, but it's not working. The button is from a group of buttons in an arraylist. When the if statement isn't there, my function works properly, but it's only when my if statement IS there that the function won't run. I know for sure that it is the correct button. This is how I have written it:
public boolean backgroundOfButton()
{
//if (buttons.get(1).getBackground().equals(Color.black))
if (buttons.get(1).getBackground() == Color.black)
{
return true;
}
else
{
return false;
}
}
I have tried the commented out version as well as the version shown. I'm not sure why it's not working.
Aucun commentaire:
Enregistrer un commentaire