I have a string called trips. In this string there are 3 values chosen by the enemy player.
I want the buttons which equals one of those values to change their color.
for(int i = 0; i <=Lobby.baanlengte;i++){
if ((trips.contains(Speler1[i].getActionCommand()))) {
System.out.println("Trips bevat"+i);
Speler1[i].setBackground(Color.gray);
}
}
Say the string trips is 3,11,14, I want the buttons 3, 11 and 14 to change their color. These buttons actually change but 1 and 4 also change since these numbers are in 11 and 14, which is not what I want.
If anyone knows how to solve this, I would appreciate that.
You should first
splitthe input string using the delimiter,, then compare each part using a.equalscomparison.