Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions