Hi, I'm trying to loop through a string and depending on the character, add a JLabel to a game. The problem is the character 'L' represents a lantern but is also used in the reply the game gives which is "LOOKREPLY". I've tried to use some code to ignore the LOOKREPLY bit but it's not working. Here's what I've tried.
else if(message.charAt(i) == 'L' && message.charAt(i+1) != 'O' | message.charAt(i+1) == 'Y'){ JLabel localLabel = new JLabel(); localLabel.setIcon(lantern); panel.add(localLabel); panel.revalidate(); panel.repaint();
But the first image on all of the JLabels is always a lantern, which is what L represents. As it's only 1 lantern this leads me to believe that it's ignoring the first 'L' but for some reason it's not ignoring the 'L' at the end of LOOKREPLY. Any idea why or perhaps a better way to go about this?
Cheers.