You shouldn't call repaint() from inside the painting method.
Applets are web based.
An inner class is useful for listeners.
Type: Posts; User: Norm
You shouldn't call repaint() from inside the painting method.
Applets are web based.
An inner class is useful for listeners.
Moving the code to another method and calling that method from the paintComponent() method changes NOTHING. The code is still WRONG.
The code in a method can set the value of a variable to tell...
The posted code does not compile without errors. Please fix the errors and repost.
Moving the code to another method and calling that method from the paintComponent() method changes NOTHING. The...
No it doesn't. The code in a method can set the value of a variable to tell the paintComponent() method what to do.
When paintComponent() method executes, it can look at the variable's values to...
Another problem I see i that the paintComponent() method ALWAYS sets the color to yellow.
The call to setColor() should either be conditional: first yellow then toggle between the other two colors...
Can you post a small, complete program that compiles, executes and shows the problem. All these pieces of code are confusing.
The Timer should not be created and started from inside the...
Yes, much better. An array of colors and modulus to pick one.
Use a couple of binary variables: firstTime and doGreen and some if statements to catch the firstTime for the yellow and then toggle the doGreen to control green and blue.