Question
Question 4) Prepare a GUI panel called ShapeSketcher for drawing a collection of shapes. It should have the following features It should contain a set
Question 4)
Prepare a GUI panel called ShapeSketcher for drawing a collection of shapes. It should have the following features
It should contain a set of five radio buttons for choosing which shape to next add to the sketch
A checkbox for whether or not the next shape should be filled in.
A button for changing the colour of the shape to next draw (the class JColorChooser might be useful)
A sketch area to show all the previously drawn shapes.
Each shape is added to the sketch by rubberbanding, dragging the mouse from its start point to a control point, with the shape being resized while the mouse is dragged.
Update the GUI so that if the mouse is dragged in a flat horizontal or flat vertical direction, the user should be informed by the letter H or V appearing alongside the current mouse position.
Add a button to clear all the shapes drawn and another button to undo the last drawn shape, careful with exceptions that could occur
Arrange components and draw area in a suitable way with suitable layouts.
HINT: May be useful to create an innerclass which also extends JPanel of a fixed size to handle the drawing of shapes and listening for mouse events.
Also recommended to place your other J components in another separate panel.
Essentially ShapeSketcher should extend JPanel and contain two more panels, one for holding the components and one for drawing the shapes and listening for mouse events objects.
Put all your JFrame setup inside the main method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started