I am trying to make a program in Java that uses both the left and right mouse buttons. The default MouseMotionListener
and MouseListener
trigger for both mouse clicks.
Is any way to determine what button is clicked?
Use the method getButton()
It returns 1 for leftClick and 3 for rightClick .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.