Class DefaultKeyboardFocusManager
- All Implemented Interfaces:
-
KeyEventDispatcher
,KeyEventPostProcessor
- Direct Known Subclasses:
FocusManager
public class DefaultKeyboardFocusManager extends KeyboardFocusManager
Please see How to Use the Focus Subsystem, a section in The Java Tutorial, and the Focus Specification for more information.
Field Summary
Fields declared in class java.awt.KeyboardFocusManager
BACKWARD_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS, FORWARD_TRAVERSAL_KEYS, UP_CYCLE_TRAVERSAL_KEYS
Constructor Summary
Constructor | Description |
---|---|
DefaultKeyboardFocusManager() |
Constructs a DefaultKeyboardFocusManager . |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
protected void |
dequeueKeyEvents |
Releases for normal dispatching to the current focus owner all KeyEvents which were enqueued because of a call to enqueueKeyEvents with the same timestamp and Component. |
protected void |
discardKeyEvents |
Discards all KeyEvents which were enqueued because of one or more calls to enqueueKeyEvents with the specified Component, or one of its descendants. |
boolean |
dispatchEvent |
This method is called by the AWT event dispatcher requesting that the current KeyboardFocusManager dispatch the specified event on its behalf. |
boolean |
dispatchKeyEvent |
Called by dispatchEvent if no other KeyEventDispatcher in the dispatcher chain dispatched the KeyEvent, or if no other KeyEventDispatchers are registered. |
void |
downFocusCycle |
Moves the focus down one focus traversal cycle. |
protected void |
enqueueKeyEvents |
Delays dispatching of KeyEvents until the specified Component becomes the focus owner. |
void |
focusNextComponent |
Focuses the Component after aComponent, typically based on a FocusTraversalPolicy. |
void |
focusPreviousComponent |
Focuses the Component before aComponent, typically based on a FocusTraversalPolicy. |
boolean |
postProcessKeyEvent |
This method will be called by dispatchKeyEvent . |
void |
processKeyEvent |
This method initiates a focus traversal operation if and only if the KeyEvent represents a focus traversal key for the specified focusedComponent. |
void |
upFocusCycle |
Moves the focus up one focus traversal cycle. |
Methods declared in class java.awt.KeyboardFocusManager
addKeyEventDispatcher, addKeyEventPostProcessor, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clearFocusOwner, clearGlobalFocusOwner, downFocusCycle, firePropertyChange, fireVetoableChange, focusNextComponent, focusPreviousComponent, getActiveWindow, getCurrentFocusCycleRoot, getCurrentKeyboardFocusManager, getDefaultFocusTraversalKeys, getDefaultFocusTraversalPolicy, getFocusedWindow, getFocusOwner, getGlobalActiveWindow, getGlobalCurrentFocusCycleRoot, getGlobalFocusedWindow, getGlobalFocusOwner, getGlobalPermanentFocusOwner, getKeyEventDispatchers, getKeyEventPostProcessors, getPermanentFocusOwner, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, redispatchEvent, removeKeyEventDispatcher, removeKeyEventPostProcessor, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setCurrentKeyboardFocusManager, setDefaultFocusTraversalKeys, setDefaultFocusTraversalPolicy, setGlobalActiveWindow, setGlobalCurrentFocusCycleRoot, setGlobalFocusedWindow, setGlobalFocusOwner, setGlobalPermanentFocusOwner, upFocusCycle
Constructor Details
DefaultKeyboardFocusManager
public DefaultKeyboardFocusManager()
DefaultKeyboardFocusManager
.Method Details
dispatchEvent
public boolean dispatchEvent(AWTEvent e)
false
, then the AWT event dispatcher will attempt to dispatch the event itself.- Specified by:
-
dispatchEvent
in classKeyboardFocusManager
- Parameters:
-
e
- the AWTEvent to be dispatched - Returns:
-
true
if this method dispatched the event;false
otherwise - See Also:
dispatchKeyEvent
public boolean dispatchKeyEvent(KeyEvent e)
dispatchEvent
if no other KeyEventDispatcher in the dispatcher chain dispatched the KeyEvent, or if no other KeyEventDispatchers are registered. If the event has not been consumed, its target is enabled, and the focus owner is not null, this method dispatches the event to its target. This method will also subsequently dispatch the event to all registered KeyEventPostProcessors. After all this operations are finished, the event is passed to peers for processing. In all cases, this method returns true
, since DefaultKeyboardFocusManager is designed so that neither dispatchEvent
, nor the AWT event dispatcher, should take further action on the event in any situation.
- Specified by:
-
dispatchKeyEvent
in interfaceKeyEventDispatcher
- Specified by:
-
dispatchKeyEvent
in classKeyboardFocusManager
- Parameters:
-
e
- the KeyEvent to be dispatched - Returns:
true
- See Also:
postProcessKeyEvent
public boolean postProcessKeyEvent(KeyEvent e)
dispatchKeyEvent
. It will handle any unconsumed KeyEvents that map to an AWT MenuShortcut
by consuming the event and activating the shortcut.- Specified by:
-
postProcessKeyEvent
in interfaceKeyEventPostProcessor
- Specified by:
-
postProcessKeyEvent
in classKeyboardFocusManager
- Parameters:
-
e
- the KeyEvent to post-process - Returns:
true
- See Also:
processKeyEvent
public void processKeyEvent(Component focusedComponent, KeyEvent e)
- Specified by:
-
processKeyEvent
in classKeyboardFocusManager
- Parameters:
-
focusedComponent
- the Component that is the basis for a focus traversal operation if the specified event represents a focus traversal key for the Component -
e
- the event that may represent a focus traversal key
enqueueKeyEvents
protected void enqueueKeyEvents(long after, Component untilFocused)
dequeueKeyEvents
or discardKeyEvents
.- Specified by:
-
enqueueKeyEvents
in classKeyboardFocusManager
- Parameters:
-
after
- timestamp of current event, or the current, system time if the current event has no timestamp, or the AWT cannot determine which event is currently being handled -
untilFocused
- Component which will receive a FOCUS_GAINED event before any pending KeyEvents - See Also:
dequeueKeyEvents
protected void dequeueKeyEvents(long after, Component untilFocused)
enqueueKeyEvents
with the same timestamp and Component. If the given timestamp is less than zero, the outstanding enqueue request for the given Component with the oldest timestamp (if any) should be cancelled.- Specified by:
-
dequeueKeyEvents
in classKeyboardFocusManager
- Parameters:
-
after
- the timestamp specified in the call toenqueueKeyEvents
, or any value < 0 -
untilFocused
- the Component specified in the call toenqueueKeyEvents
- See Also:
discardKeyEvents
protected void discardKeyEvents(Component comp)
enqueueKeyEvents
with the specified Component, or one of its descendants.- Specified by:
-
discardKeyEvents
in classKeyboardFocusManager
- Parameters:
-
comp
- the Component specified in one or more calls toenqueueKeyEvents
, or a parent of such a Component - See Also:
focusPreviousComponent
public void focusPreviousComponent(Component aComponent)
- Specified by:
-
focusPreviousComponent
in classKeyboardFocusManager
- Parameters:
-
aComponent
- the Component that is the basis for the focus traversal operation - See Also:
focusNextComponent
public void focusNextComponent(Component aComponent)
- Specified by:
-
focusNextComponent
in classKeyboardFocusManager
- Parameters:
-
aComponent
- the Component that is the basis for the focus traversal operation - See Also:
upFocusCycle
public void upFocusCycle(Component aComponent)
- Specified by:
-
upFocusCycle
in classKeyboardFocusManager
- Parameters:
-
aComponent
- the Component that is the basis for the focus traversal operation - See Also:
downFocusCycle
public void downFocusCycle(Container aContainer)
- Specified by:
-
downFocusCycle
in classKeyboardFocusManager
- Parameters:
-
aContainer
- the Container that is the basis for the focus traversal operation - See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/DefaultKeyboardFocusManager.html