|
JavaTM 2 Platform Std. Ed. v1.4.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A KeyEventDispatcher cooperates with the current KeyboardFocusManager in the targeting and dispatching of all KeyEvents. KeyEventDispatchers registered with the current KeyboardFocusManager will receive KeyEvents before they are dispatched to their targets, allowing each KeyEventDispatcher to retarget the event, consume it, dispatch the event itself, or make other changes.
Note that KeyboardFocusManager itself implements KeyEventDispatcher. By default, the current KeyboardFocusManager will be the sink for all KeyEvents not dispatched by the registered KeyEventDispatchers. The current KeyboardFocusManager cannot be completely deregistered as a KeyEventDispatcher. However, if a KeyEventDispatcher reports that it dispatched the KeyEvent, regardless of whether it actually did so, the KeyboardFocusManager will take no further action with regard to the KeyEvent. (While it is possible for client code to register the current KeyboardFocusManager as a KeyEventDispatcher one or more times, this is usually unnecessary and not recommended.)
KeyboardFocusManager.addKeyEventDispatcher(java.awt.KeyEventDispatcher)
,
KeyboardFocusManager.removeKeyEventDispatcher(java.awt.KeyEventDispatcher)
Method Summary | |
boolean |
dispatchKeyEvent(KeyEvent e)
This method is called by the current KeyboardFocusManager requesting that this KeyEventDispatcher dispatch the specified event on its behalf. |
Method Detail |
public boolean dispatchKeyEvent(KeyEvent e)
redispatchEvent
to prevent the current KeyboardFocusManager from recursively requesting
that this KeyEventDispatcher dispatch the event again.
If an implementation of this method returns false
, then
the KeyEvent is passed to the next KeyEventDispatcher in the chain,
ending with the current KeyboardFocusManager. If an implementation
returns true
, the KeyEvent is assumed to have been
dispatched (although this need not be the case), and the current
KeyboardFocusManager will take no further action with regard to the
KeyEvent. In such a case,
KeyboardFocusManager.dispatchEvent
should return
true
as well. If an implementation consumes the KeyEvent,
but returns false
, the consumed event will still be passed
to the next KeyEventDispatcher in the chain. It is important for
developers to check whether the KeyEvent has been consumed before
dispatching it to a target. By default, the current KeyboardFocusManager
will not dispatch a consumed KeyEvent.
e
- the KeyEvent to dispatch
true
if the KeyboardFocusManager should take no
further action with regard to the KeyEvent; false
otherwiseKeyboardFocusManager.redispatchEvent(java.awt.Component, java.awt.AWTEvent)
|
JavaTM 2 Platform Std. Ed. v1.4.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.