Please refer to the following UML diagrams:
PanelRaduis extends JPanel
- label: JLabel - textField: JTextField |
+ PanelRadius() + getRadius() |
PanelCircle extends JPanel
- radius: int - rgb: int |
+ PanelCircle() + setRadius(int): void + setRGB(int): void + setRadiusAndRGB(int, int): void + paintComponent(Graphics): void |
PanelRGB extends JPanel implements ActionListener
- label: JLabel - textField: JTextField - enter: JButton - rgb: int - pr: PanelRadius - pc: PanelCircle |
+ PanelRGB(PanelRadius, PanelCircle) + actionPerformed(ActionEvent e) |
The driven class is given as:
import javax.swing.*;
import java.awt.*;
public class DisplayWindow
{
public static void main(String[] args)
{
JFrame w1 = new JFrame("Display Window");
w1.setLayout(new GridLayout(3,1));
PanelRaduis myPanel = new PanelRaduis();
PanelCircle panel3 = new PanelCircle();
w1.add(myPanel);
PanelRGB yourPanel = new PanelRGB(myPanel,panel3);
w1.add(yourPanel);
w1.add(panel3);
w1.setSize(500, 800);
w1.setVisible(true);
w1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Please implement all the 3 classes to ensure the application working.
The expected result is shown as the image at the end of this document.
The user is asked to provide an integer value for Raduis, and an integer value for RGB. A Circle will be drawn when "Enter" clicked. see image.