On my three button mouse MouseEvent.BUTTON2
= Middle Click and MouseEvent.BUTTON3
= Right Click.
Is this the case on a two button mouse?
Thanks
BUTTON2 = Middle Click and MouseEvent. BUTTON3 = Right Click.
public class MouseEvent extends InputEvent. An event which indicates that a mouse action occurred in a component. A mouse action is considered to occur in a particular component if and only if the mouse cursor is over the unobscured part of the component's bounds when the action happens.
Methods of MouseListener interfacepublic abstract void mouseClicked(MouseEvent e); public abstract void mouseEntered(MouseEvent e); public abstract void mouseExited(MouseEvent e); public abstract void mousePressed(MouseEvent e);
To avoid any ambiguity, use the utilities methods from SwingUtilities :
SwingUtilities.isLeftMouseButton(MouseEvent anEvent)
SwingUtilities.isRightMouseButton(MouseEvent anEvent)
SwingUtilities.isMiddleMouseButton(MouseEvent anEvent)
Yes, take a look at this thread which talks about the differences between platforms.
How to detect right-click event for Mac OS
BUTTON3
is the same across all platforms, being equal to the right mouse button. BUTTON2 is simply ignored if the middle button does not exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With