The mouse listener interface allows you to retrieve mouse


Question: The Mouse Listener interface allows you to retrieve mouse events. A program implements this interface in a manner similar to the Window Listener interface. For example, the following program creates a J Frame and outputs the X and Y coordinates of any mouse clicks within the J Frame. The Mouse Listener interface requires the implementing class to define the mouse Clicked, mouse Entered, mouse Pressed, mouse Released, and mouse Exited methods. In the example, only the mouse Clicked method has been completed.

697_1.jpg

Modify this program to create a simple drawing program. When the mouse button is clicked, a solid circle with a radius of three pixels should be drawn in the J Frame centered at the mouse coordinates. Draw the circle in the color of your choice. Make sure that the drawing is correctly redrawn if the J Frame is minimized and then displayed again.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: The mouse listener interface allows you to retrieve mouse
Reference No:- TGS02405505

Now Priced at $10 (50% Discount)

Recommended (93%)

Rated (4.5/5)