问题
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