0

I have been working on this program for a couple of days now and thought I figured out a good way to do user input. When I tried it, Java appeared to just skip the loop. The while loop being skipped is:

 while(textIN.getText() == "1")
 {
  final String text = textIN.getText();
  key = text.charAt(0);
 }

 while (length < lengthtemp)
 {
  Word = Word + WordD[length];
  length++;
 }

 while (lives > 0)
 {
  JOptionPane.showMessageDialog(null,"EnterLoop");
  while(textIN.getText() == "1")
  {      
   final String text = textIN.getText();
   key = text.charAt(0);
   JOptionPane.showMessageDialog(null,"WORK");
  }

  JOptionPane.showMessageDialog(null,"KeyPressed");
  length = 0;
  String TextTemp = Text.toString();
  while (length < lengthtemp)
  {
   if (key == WordD[length])
   {
    Text.setCharAt(length, WordD[length]);
    JOptionPane.showMessageDialog(null,"Correct Letter");
    Label.setText(Text.toString());
    if (Text.toString() == Word)
    {
     lives=-1;
    }
   }
   length++;
  }

  if (TextTemp == Text.toString())
  {
   lives--;
  }
 }
 if (lives == -1)
 {
  JOptionPane.showMessageDialog(null,"You Win");
 }

Thanks for the help.

bwegs
  • 3,769
  • 2
  • 30
  • 33

0 Answers0