Question: Just need some help filling in the code... Thanks Complete a program to draw circles, arranged in a grid. For example, 6 circles arranged in
Complete a program to draw circles, arranged in a grid. For example, 6 circles arranged in a 2 by 3 grid would look like this: How does it work? The main method prompts the user for the grid parameters, the number of rows and number of columns. The remaining code in main, creates a graphic window and calls the draw method to actually complete the graphic. The draw method should contain code that uses a loop (or loops) to draw each circle. A circle is draw using the drawOval method applied to the graphic object g. The drawOval method is defined as drawOval(int x, int y, int width, int height) Draws the outline of an oval. The result is a circle or ellipse that fits within the rectangle specified by the x, y, width, and height arguments. x and y are the coordinates of the circle measured in pixels from the upper lefthand corner of the window. A suitable width and height is 40 pixels. import java.awt.Graphics; import java.util.scanneri import javaz.swing. JFrane ; import javax.swing.JComponent public class Lab4c public static void draw (Graphics g, int a, int b) /I Your code goes here public static void main (String args) int a, bi // Your code to prompt the user for the grid size-a and b JFrame frame new JFrame ( ); final int FRAME WIDTH400 final int FRAME-HEIGHT = 400; frame.setsize(FRAME_WIDTH, FRAME HEIGHT) frame.setDefaultCloseoperation (JFrame.EXIT ON CLOSE) JComponent componentnew JComponent
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
