Question: 4.2. Write a program that displays a frame with the following GUI elements: - a label that displays a simple icon with a circle initially
4.2. Write a program that displays a frame with the following GUI elements: - a label that displays a simple icon with a circle initially colored solid red - a button labeled "Green" - a button labeled "Blue" - a button labeled "Red" When the user clicks a button, the circle color must change to that indicated by the button's label. Implementation requirements: i) when a button is clicked you need to change the icon's color, then call the label's repaint() method. This, in turn will call the icon's painticon() method, so that the icon is redrawn with the new color. In other words, you don't call painticon) directly, the JLabel object does it. ii) the buttons' action listener objects must be of anonymous classes. iii) the buttons must be created in main() and set up in a loop with loop index from 0 to 2, like this: for (i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
