Question: Design and write a program that displays a frame with the following GUI elements: - a label that displays a simple icon with a rectangle

Design and write a program that displays a frame with the following GUI elements: - a label that displays a simple icon with a rectangle initially colored solid yellow - a button labeled "Red" - a button labeled "Yellow" - a button labeled "Blue" When the user clicks a button, the rectangle color must change to that indicated by the button's label. a) Write the UML class diagram showing the classes and relationships between them Make sure to include classes/interfaces for the icon, listener, frame, label. Include the diagram in the PDF file. b) Write the UML sequence diagram describing the interactions between objects when the user clicks on one of the buttons. Include the diagram in the PDF file. The algorithm is given below c) Write the program in Java using the Swing librar Implementation requirements & hints: 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
