Java; Component.enableEvents ( ... ) does not work?
Recently, I discovered the Component.enableEvents ( ... ) method. The way that I would imagine that it would work would be that Component.enableEvents ( MouseEvent.MOUSE_PRESSED )
would only alert me if that specific event happened. However, it does not work like that, or I just cannot figure it out.
Right now, I have this code:
frame.enableEvents(FocusEvent.FOCUS_GAINED | FocusEvent.FOCUS_LOST | ComponentEvent.COMPONENT_RESIZED);
Bu开发者_Go百科t I still find that I get component moved events, component hidden, etc. What am I doing wrong?
From the JavaDoc for that method:
This method only needs to be invoked by subclasses of Component which desire to have the specified event types delivered to processEvent regardless of whether or not a listener is registered.
This says nothing about filtering out event types that are not named.
精彩评论