Make a JFrame with a panel and a label in the panel. After each delay, change th
ID: 3560663 • Letter: M
Question
Make a JFrame with a panel and a label in the panel. After each delay, change the background color of the panel and the foreground color of the label. How you change the color is up to you (randomly, from an array, in a specific sequence, etc.). I suggest you create a method to change the colors that runs once through like in the for loop example or in an infinite loop. If using an infinite loop, make sure you can continue to change the numbers indefinitely. Remember that the method that runs the loop will need to have access to the label and panel (probably best to make them data members of the class).
Explanation / Answer
I also agree with Reimeus's comment. There is no need to extend JPanel to do this functionality. Just do:
Or even easier, since you are just adding one component to the panel, there is no need to even create the panel. Just do:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.