12.14 Mouse and Touch Events
A truly interactive application allows the user to point and click using the mouse or to touch the screen. Any mouse activity (clicking, moving, or dragging) by the user generates a MouseEvent. Any touch activity by the user generates a TouchEvent. When any mouse or touch activity occurs, we will be interested in determining where it happened on the window. To determine the (x, y) coordinate of a mouse event, we can call two methods of the MouseEvent class, getSceneX and getSceneY, which are described in Table 12.42. To determine the (x, y) coordinate of a touch event, we can first call the getTouchPoint method of the TouchEvent class, which returns a TouchPoint, and then call the getSceneX and getSceneY methods ...
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.