Question: how to draw shapes in java add shapes with lift click and remove with right click java Creating, drawing, and removing simple geometric shapes In

how to draw shapes in java add shapes with lift click and remove with right click

java

Creating, drawing, and removing simple geometric shapes

In this lab you will create a Java class that lets the user add shapes to a JPanel with a left-click, and remove them with a right-click. Your Class should be implemented in a single Java file (ShapeClicker.java). starting with the example we saw showing how to add new shapes to the screen upon mouse-click, and work from there. Several additional requirements are listed below:

1. Shapes should be spawned upon LEFT CLICK. You may pick the shape circle is what we saw in class, but anything is fine. The shape should appear centered on the mouse.

2. If the user RIGHT CLICKS within the filled portion of a shape, that shape should disappear.

Hint: You know the x, y coordinates of each shape

3. The color of every shape should be different! Spice things up a bit. The background color can be anything you want. Just dont make it hurt my eyes.

4. Only 10 shapes are allowed on the screen at a time. Once there are 10 shapes, a LEFT CLICK should do nothing. Only when the user successfully removes a shape can they add another.

5. Your ShapeClicker window should be instantiated in the main method using a single statement, just like weve been seeing in class:

ShapeClicker click = new ShapeClicker();

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 Databases Questions!