Basic HTML version of Foils prepared July 10 1996

Foil 33 Using Mouse Events for User Interaction

From Introductory Lectures on Java -- An Overview Mixing Code and Comments Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox


We set up a test program that creates 3 movable objects, a rectangle, circle and triangle, as in the earlier example. In this program, we start with them all red. Whenever the mouse is detected to be over one of the objects, its color is changed to cyan. If the mouse button is used to drag the object, we move the object to the mouse location.
Note that it is not necessary to introduce a thread for this applet since it is not running continuously - it is mostly waiting for mouse events.



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Dec 14 1997