Java Mouse Event Right Click

On my mouse button, MouseEvent.BUTTON2 = middle click and MouseEvent.BUTTON3 = right click.

Is this in the case of a two-button mouse?

thank

+69
java swing mouse right-click
Dec 24 '10 at 10:29
source share
3 answers

To avoid any ambiguity, use the utility methods from SwingUtilities :

SwingUtilities.isLeftMouseButton(MouseEvent anEvent) SwingUtilities.isRightMouseButton(MouseEvent anEvent) SwingUtilities.isMiddleMouseButton(MouseEvent anEvent)

+139
Dec 24 '10 at 10:40
source share

Yes, take a look at this thread, which talks about the differences between the platforms.

How to detect a right-click event for Mac OS

BUTTON3 same on all platforms, equal to the right mouse button. BUTTON2 is simply ignored if the middle button does not exist.

+8
Dec 24 '10 at 10:37
source share

I have seen

 anEvent.isPopupTrigger() 

. I am new to Java, so I'm glad to hear thoughts about this approach :)

+1
Jun 29 '13 at 2:00
source share



All Articles