e646. 处理鼠标点击事件

时间:2022-10-06 05:51:14
component.addMouseListener(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());
}
}
}
Related Examples