Question: Draw three rectangles inside each other, like in the picture. please share the screenshot of the output and use comments in code CoursHeroTranscribedText DrawingComponent.java 1
Draw three rectangles inside each other, like in the picture.
please share the screenshot of the output and use comments in code


CoursHeroTranscribedText
DrawingComponent.java 1 import java.awt.Graphics; 2 import javax.swing.J Component; 123456700 public class DrawingComponent extends Component 5 { 1 1 } public void paintComponent (Graphics g) { } g.drawRectangle(100, 100, 20, 30); // Innermost rectangle DrawingViewer.java 1 import javax.swing.*; 2 3 public class DrawingViewer 40 public static void main(String[] args) JFrame frame = new JFrame(); frame.setSize(300, 400); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.add(component); 1 1 DrawingComponent component = new DrawingComponent(); 1 1 frame.setVisible(true); 1 } 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
