Writing a guessing game program. The user is to guess a number between 1 - 1000. Every time the user guesses too low, the background color of the JFrame is to change to blue, if the user guesses too high, it changes to red. I cannot get the background color to change at all. Everything else seems to running ok with the program. Any help would be appreciated. Thanks. Here is my code:
Don't call setBackground from paintComponent. That will trigger another repaint which will call paintComponent again. Instead of using your variable "background" just call setBackground in your event handlers.
And you're calling super.paintComponents instead of super.paintComponent. Because both methods exist you didn't get a compiler error but you should definitely fix that.