e646. 处理鼠标点击事件

    
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
posted @ 2018-09-02 21:28  borter  阅读(219)  评论(0编辑  收藏  举报