Write a canvas that implements the mousemotionlistener


Question:

a) Write a canvas that implements the MouseMotionListener interface and add itself as its own MouseMotionListener . Make your program draw small filled rectangles as the mouse is dragged. Congratulations: you've recreated the basics of MacPaint!

b) Extend the previous canvas to do the following. When the mouse is first pressed, draw a small rectangle as above. As the mouse is dragged, draw a line connecting the original point to the current position of the mouse.

Erase the previous line first so that your canvas doesn't get covered in black. When the mouse is released, leave the last line on the canvas. Think about what you need to keep track of between events to make this work. This needs to be part of the state of your canvas.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a canvas that implements the mousemotionlistener
Reference No:- TGS02910958

Expected delivery within 24 Hours