Can't filter MouseEvent.MOUSE_CLICKED in AWT EventQueue

无人久伴 提交于 2019-12-11 20:12:09

问题


I need in my own AWT EventQueue filtering mouse double clicks, so I do:

public class AppEventQueue extends EventQueue
{
@Override
protected void dispatchEvent(AWTEvent event)
{
    super.dispatchEvent(event);
    if(event instanceof MouseEvent)
    {
        MouseEvent mouseEvent = (MouseEvent) event;
        if(mouseEvent.getModifiers() == MouseEvent.MOUSE_CLICKED)
        {
            //do something
        }
    }
}
}

Problem I have is that it looks that click with mouse is generating int value 16, MouseEvent.MOUSE_CLICKED has value 500. Am I missing something?


回答1:


you want to check the id:

if (mouseEvent.getID() == MouseEvent.MOUSE_CLICKED {

}


来源:https://stackoverflow.com/questions/15513139/cant-filter-mouseevent-mouse-clicked-in-awt-eventqueue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!