Question: Write a Java program that does the following a . When the user presses the mouse button, draw a blue rectangle that completely fills the

Write a Java program that does the following
a. When the user presses the mouse button, draw a blue rectangle that completely fills the JPanel and that has a 10 pixel black border (i.e., the rectangle has the black border).
b. When the user releases the mouse button, draw a green rectangle that completely fills the JPanel and that has a 10 pixel black border (i.e., the rectangle has the black border).
c. The JPanel should initially appear as a 100\times 100 pixel object but it can be resized.
d. The JPanel should be added to the center of its JFrame's content pane.
Below is Example GUI
When the mouse is pressed, a blue rectangle is drawn that completely fills the JPanel
When the mouse is released, a green rectangle is drawn that completely fills the JPanel
Write a Java program that does the following a .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!