Question: Write a program named Pattern that uses the DrawingPanel class provided by the textbook to create a drawing panel (canvas) with a width of 540
Write a program named Pattern that uses the DrawingPanel class provided by the textbook to create a drawing panel (canvas) with a width of 540 pixels and an height of 540 pixels.
Prompt the user for the number of rows and columns for the pattern. The numbers should be between 1 and 10. Convert numbers below 1 to 1 and numbers above 10 to 10. Then prompt the user for the Red, Green, and Blue values used to create the custom color for the pattern. These values should be between 0 and 255 -- convert numbers below 0 to 0 and numbers above 255 to 255.
Then draw a pattern with the given number of rows and columns of circles inside squares. Each circle and square should be 50 pixels wide. The (x, y) coordinates used to draw the first circle/square in the first row should be (20, 20).
After drawing all of the circles and squares, output a message to the user to close the Drawing Panel in order to exit the program.
For example, the input below,
csc$ java Pattern Number of rows (1-10): 4 Number of columns (1-10): 8 Red value (0-255): 240 Green value (0-255): 68 Blue value (0-255): 75 *CLOSE the Drawing Panel to exit the program*
would result in the following pattern shown below:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
