public class MyMouseListener extends MouseAdapter {
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 3) {
// 处理鼠标三击
} else if (evt.getClickCount() == 2) {
// 处理鼠标双击
}
}
}
处理鼠标右键
public mouseClicked(MouseEvent e){
if(e.isMetaDown()){//检测鼠标右键单击
}
如何在小程序中处理鼠标中间键?
new MyMouseListener());
public class MyMouseListener extends MouseAdapter {
public void mouseClicked(MouseEvent evt) {
if ((evt.getModifiers() &?
InputEvent.BUTTON1_MASK) != 0) {
processLeft(evt.getPoint());
//处理鼠标左键单击
}
if ((evt.getModifiers() &?
InputEvent.BUTTON2_MASK) != 0) {
processMiddle(evt.getPoint());
//处理鼠标中间键单击
}
if ((evt.getModifiers() &?
InputEvent.BUTTON3_MASK) != 0) {
processRight(evt.getPoint());
//处理鼠标右键单击
java swing鼠标双击和右键事件处理
最新推荐文章于 2024-09-13 08:51:44 发布