[英]How do I determine if the left or right mouse button was clicked in Java?
I am trying to make a program in Java that uses both the left and right mouse buttons. 我正在尝试使用Java编写同时使用鼠标左键和鼠标右键的程序。 The default
MouseMotionListener
and MouseListener
trigger for both mouse clicks. 默认的
MouseMotionListener
和MouseListener
触发两次鼠标单击。
Is any way to determine what button is clicked? 有什么方法可以确定单击了哪个按钮?
Use the method getButton()
使用方法
getButton()
It returns 1 for leftClick and 3 for rightClick . 它为leftClick返回1, 为rightClick返回3 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.