Section 12.14 Mouse Event Handling

• The MouseListener (p. 513) and MouseMotionListener (p. 513) event-listener interfaces are used to handle mouse events (p. 513). Mouse events can be trapped for any GUI component that extends Component.

• Interface MouseInputListener (p. 513) of package javax.swing.event extends interfaces MouseListener and MouseMotionListener to create a single interface containing all their methods.

• Each mouse event-handling method receives a MouseEvent object (p. 494) that contains information about the event, including the x- and y-coordinates where the event occurred. Coordinates are measured from the upper-left corner of the GUI component on which the event occurred.

• The methods and constants of class InputEvent ...

Get Java™ How To Program (Early Objects), Tenth 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.