Originally Posted by
EatMyBible
Once again, you guys helped me and I learned something in the process. That loop would've run countless times, thus it froze the program. Using a loop in that case was meaningless from the beginning, as my intent was to create a counter for how many times the user had guessed a number. Like Kevin said, I reconsidered my logic and realized that once the button is pushed, it goes through all the stuff inside of the ActionListener. Thus, I had to create a private int within the actionlistener, but outside its public void, and simply set forsok++; inside of the listener, as it would run through it every time the button is pressed.
Thanks, appreciate it.
I believe your forsok variable could also be a class variable in the outer class as well, that way you can access it from other methods.
Originally Posted by
EatMyBible
EDIT: Any suggestions on basic tasks with loops in Swing that I can play around with?
You could implement a Game of Nim type thing, or a loan/bill calculator, or a grade tracker.. the possibilities are endless, and really depend on your interests.