I'm having trouble getting this while loop to stop and look for a new input. Obviously the while loop is infinite because I don't get new input. I know this is easy but I'm still stuck

here is my while loop

while (guessInt != randInt){
    guessInt = Integer.parseInt(GuessGame.numberField.getText());
	if (guessInt != randInt){
		if (guessInt > prevGuess ){
			setMessage(new JTextField("You're getting colder"));
		if (guessInt < prevGuess ){
			setMessage(new JTextField("You're getting warmer"));

and I need to grap new information from a JButton in a different class

JButton guessButton = new JButton("Guess");
GuessHandler guessHandler = new GuessHandler();

Can anyone please help this idiot?

If you are using a Swing Form to get Input then I would suggest dropping the while loop altogether because your actionPerformed() method will be called whenever your user clicks on the GuessButton and you can perform all the necessary processing then.

I was wondering about that this morning, I hit the button to call it but I thought I was going to have to put a listener or something back in the loop for the button, but you're right, I won't need the while at all...


This question has already been answered. Start a new discussion instead.