Of Mice and Buttons

Different platforms typically use different types of mice. Macintosh systems normally use a one-button mouse, PCs a two- or three-button mouse, and SPARC® systems a three-button mouse. Java deals with these differences by assuming that all mice have one button. For example, the AWT distinguishes only one mouse up event. Correspondingly, there is only one method (mouseUp()) to account for this. There's no mouseUp1(), mouseUp2(), mouseUp3() to account for the different mouse buttons that might initiate an event. This is also the case for mouse events such as a mouse down or mouse drag.

As we've seen in the whichMouseButton method above, the mechanism employed to determine which mouse button triggered an event is to look at the ...

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.