DefaultKeyboardFocusManager (Java 2 Platform SE 5.0) (original) (raw)
java.lang.Object
java.awt.KeyboardFocusManager
java.awt.DefaultKeyboardFocusManager
All Implemented Interfaces:
KeyEventDispatcher, KeyEventPostProcessor
Direct Known Subclasses:
public class DefaultKeyboardFocusManager
extends KeyboardFocusManager
The default KeyboardFocusManager for AWT applications. Focus traversal is done in response to a Component's focus traversal keys, and using a Container's FocusTraversalPolicy.
Please see How to Use the Focus Subsystem, a section in The Java Tutorial, and theFocus Specification for more information.
Since:
1.4
See Also:
FocusTraversalPolicy, [Component.setFocusTraversalKeys(int, java.util.Set)](../../java/awt/Component.html#setFocusTraversalKeys%28int, java.util.Set%29), Component.getFocusTraversalKeys(int)
Field Summary |
---|
Fields inherited from class java.awt.KeyboardFocusManager |
---|
BACKWARD_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS, FORWARD_TRAVERSAL_KEYS, UP_CYCLE_TRAVERSAL_KEYS |
Constructor Summary |
---|
DefaultKeyboardFocusManager() |
Method Summary | |
---|---|
protected void | [dequeueKeyEvents](../../java/awt/DefaultKeyboardFocusManager.html#dequeueKeyEvents%28long, java.awt.Component%29)(long after,Component untilFocused) Releases for normal dispatching to the current focus owner all KeyEvents which were enqueued because of a call toenqueueKeyEvents with the same timestamp and Component. |
protected void | discardKeyEvents(Component comp) 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(AWTEvent e) This method is called by the AWT event dispatcher requesting that the current KeyboardFocusManager dispatch the specified event on its behalf. |
boolean | dispatchKeyEvent(KeyEvent e) Called by dispatchEvent if no other KeyEventDispatcher in the dispatcher chain dispatched the KeyEvent, or if no other KeyEventDispatchers are registered. |
void | downFocusCycle(Container aContainer) Moves the focus down one focus traversal cycle. |
protected void | [enqueueKeyEvents](../../java/awt/DefaultKeyboardFocusManager.html#enqueueKeyEvents%28long, java.awt.Component%29)(long after,Component untilFocused) Delays dispatching of KeyEvents until the specified Component becomes the focus owner. |
void | focusNextComponent(Component aComponent) Focuses the Component after aComponent, typically based on a FocusTraversalPolicy. |
void | focusPreviousComponent(Component aComponent) Focuses the Component before aComponent, typically based on a FocusTraversalPolicy. |
boolean | postProcessKeyEvent(KeyEvent e) This method will be called by dispatchKeyEvent. |
void | [processKeyEvent](../../java/awt/DefaultKeyboardFocusManager.html#processKeyEvent%28java.awt.Component, java.awt.event.KeyEvent%29)(Component focusedComponent,KeyEvent e) This method initiates a focus traversal operation if and only if the KeyEvent represents a focus traversal key for the specified focusedComponent. |
void | upFocusCycle(Component aComponent) Moves the focus up one focus traversal cycle. |
Methods inherited from class java.awt.KeyboardFocusManager |
---|
addKeyEventDispatcher, addKeyEventPostProcessor, addPropertyChangeListener, [addPropertyChangeListener](../../java/awt/KeyboardFocusManager.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), [addVetoableChangeListener](../../java/awt/KeyboardFocusManager.html#addVetoableChangeListener%28java.lang.String, java.beans.VetoableChangeListener%29), addVetoableChangeListener, clearGlobalFocusOwner, downFocusCycle, [firePropertyChange](../../java/awt/KeyboardFocusManager.html#firePropertyChange%28java.lang.String, java.lang.Object, java.lang.Object%29), [fireVetoableChange](../../java/awt/KeyboardFocusManager.html#fireVetoableChange%28java.lang.String, java.lang.Object, java.lang.Object%29), focusNextComponent, focusPreviousComponent, getActiveWindow, getCurrentFocusCycleRoot, getCurrentKeyboardFocusManager, getDefaultFocusTraversalKeys, getDefaultFocusTraversalPolicy, getFocusedWindow, getFocusOwner, getGlobalActiveWindow, getGlobalCurrentFocusCycleRoot, getGlobalFocusedWindow, getGlobalFocusOwner, getGlobalPermanentFocusOwner, getKeyEventDispatchers, getKeyEventPostProcessors, getPermanentFocusOwner, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, [redispatchEvent](../../java/awt/KeyboardFocusManager.html#redispatchEvent%28java.awt.Component, java.awt.AWTEvent%29), removeKeyEventDispatcher, removeKeyEventPostProcessor, removePropertyChangeListener, [removePropertyChangeListener](../../java/awt/KeyboardFocusManager.html#removePropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), [removeVetoableChangeListener](../../java/awt/KeyboardFocusManager.html#removeVetoableChangeListener%28java.lang.String, java.beans.VetoableChangeListener%29), removeVetoableChangeListener, setCurrentKeyboardFocusManager, [setDefaultFocusTraversalKeys](../../java/awt/KeyboardFocusManager.html#setDefaultFocusTraversalKeys%28int, java.util.Set%29), setDefaultFocusTraversalPolicy, setGlobalActiveWindow, setGlobalCurrentFocusCycleRoot, setGlobalFocusedWindow, setGlobalFocusOwner, setGlobalPermanentFocusOwner, upFocusCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
DefaultKeyboardFocusManager
public DefaultKeyboardFocusManager()
Method Detail |
---|
dispatchEvent
public boolean dispatchEvent(AWTEvent e)
This method is called by the AWT event dispatcher requesting that the current KeyboardFocusManager dispatch the specified event on its behalf. DefaultKeyboardFocusManagers dispatch all FocusEvents, all WindowEvents related to focus, and all KeyEvents. These events are dispatched based on the KeyboardFocusManager's notion of the focus owner and the focused and active Windows, sometimes overriding the source of the specified AWTEvent. If this method returns false
, then the AWT event dispatcher will attempt to dispatch the event itself.
Specified by:
[dispatchEvent](../../java/awt/KeyboardFocusManager.html#dispatchEvent%28java.awt.AWTEvent%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
e
- the AWTEvent to be dispatched
Returns:
true
if this method dispatched the event;false
otherwise
See Also:
[KeyboardFocusManager.redispatchEvent(java.awt.Component, java.awt.AWTEvent)](../../java/awt/KeyboardFocusManager.html#redispatchEvent%28java.awt.Component, java.awt.AWTEvent%29), KeyboardFocusManager.dispatchKeyEvent(java.awt.event.KeyEvent)
dispatchKeyEvent
public boolean dispatchKeyEvent(KeyEvent e)
Called by 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 neitherdispatchEvent
, nor the AWT event dispatcher, should take further action on the event in any situation.
Specified by:
[dispatchKeyEvent](../../java/awt/KeyEventDispatcher.html#dispatchKeyEvent%28java.awt.event.KeyEvent%29)
in interface [KeyEventDispatcher](../../java/awt/KeyEventDispatcher.html "interface in java.awt")
Specified by:
[dispatchKeyEvent](../../java/awt/KeyboardFocusManager.html#dispatchKeyEvent%28java.awt.event.KeyEvent%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
e
- the KeyEvent to be dispatched
Returns:
true
See Also:
Component.dispatchEvent(java.awt.AWTEvent)
postProcessKeyEvent
public boolean postProcessKeyEvent(KeyEvent e)
This method will be called by dispatchKeyEvent
. It will handle any unconsumed KeyEvents that map to an AWTMenuShortcut
by consuming the event and activating the shortcut.
Specified by:
[postProcessKeyEvent](../../java/awt/KeyEventPostProcessor.html#postProcessKeyEvent%28java.awt.event.KeyEvent%29)
in interface [KeyEventPostProcessor](../../java/awt/KeyEventPostProcessor.html "interface in java.awt")
Specified by:
[postProcessKeyEvent](../../java/awt/KeyboardFocusManager.html#postProcessKeyEvent%28java.awt.event.KeyEvent%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
e
- the KeyEvent to post-process
Returns:
true
See Also:
dispatchKeyEvent(java.awt.event.KeyEvent), MenuShortcut
processKeyEvent
public void processKeyEvent(Component focusedComponent, KeyEvent e)
This method initiates a focus traversal operation if and only if the KeyEvent represents a focus traversal key for the specified focusedComponent. It is expected that focusedComponent is the current focus owner, although this need not be the case. If it is not, focus traversal will nevertheless proceed as if focusedComponent were the focus owner.
Specified by:
[processKeyEvent](../../java/awt/KeyboardFocusManager.html#processKeyEvent%28java.awt.Component, java.awt.event.KeyEvent%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
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)
Delays dispatching of KeyEvents until the specified Component becomes the focus owner. KeyEvents with timestamps later than the specified timestamp will be enqueued until the specified Component receives a FOCUS_GAINED event, or the AWT cancels the delay request by invokingdequeueKeyEvents
or discardKeyEvents
.
Specified by:
[enqueueKeyEvents](../../java/awt/KeyboardFocusManager.html#enqueueKeyEvents%28long, java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
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(long, java.awt.Component)](../../java/awt/DefaultKeyboardFocusManager.html#dequeueKeyEvents%28long, java.awt.Component%29), discardKeyEvents(java.awt.Component)
dequeueKeyEvents
protected void dequeueKeyEvents(long after, Component untilFocused)
Releases for normal dispatching to the current focus owner all KeyEvents which were enqueued because of a call toenqueueKeyEvents
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](../../java/awt/KeyboardFocusManager.html#dequeueKeyEvents%28long, java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
after
- the timestamp specified in the call toenqueueKeyEvents
, or any value < 0
untilFocused
- the Component specified in the call toenqueueKeyEvents
See Also:
[enqueueKeyEvents(long, java.awt.Component)](../../java/awt/DefaultKeyboardFocusManager.html#enqueueKeyEvents%28long, java.awt.Component%29), discardKeyEvents(java.awt.Component)
discardKeyEvents
protected void discardKeyEvents(Component comp)
Discards all KeyEvents which were enqueued because of one or more calls to enqueueKeyEvents
with the specified Component, or one of its descendants.
Specified by:
[discardKeyEvents](../../java/awt/KeyboardFocusManager.html#discardKeyEvents%28java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
comp
- the Component specified in one or more calls toenqueueKeyEvents
, or a parent of such a Component
See Also:
[enqueueKeyEvents(long, java.awt.Component)](../../java/awt/DefaultKeyboardFocusManager.html#enqueueKeyEvents%28long, java.awt.Component%29), [dequeueKeyEvents(long, java.awt.Component)](../../java/awt/DefaultKeyboardFocusManager.html#dequeueKeyEvents%28long, java.awt.Component%29)
focusPreviousComponent
public void focusPreviousComponent(Component aComponent)
Focuses the Component before aComponent, typically based on a FocusTraversalPolicy.
Specified by:
[focusPreviousComponent](../../java/awt/KeyboardFocusManager.html#focusPreviousComponent%28java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
aComponent
- the Component that is the basis for the focus traversal operation
See Also:
FocusTraversalPolicy, Component.transferFocusBackward()
focusNextComponent
public void focusNextComponent(Component aComponent)
Focuses the Component after aComponent, typically based on a FocusTraversalPolicy.
Specified by:
[focusNextComponent](../../java/awt/KeyboardFocusManager.html#focusNextComponent%28java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
aComponent
- the Component that is the basis for the focus traversal operation
See Also:
FocusTraversalPolicy, Component.transferFocus()
upFocusCycle
public void upFocusCycle(Component aComponent)
Moves the focus up one focus traversal cycle. Typically, the focus owner is set to aComponent's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, aComponent's focus cycle root is a Window, then the focus owner is set to the focus cycle root's default Component to focus, and the current focus cycle root is unchanged.
Specified by:
[upFocusCycle](../../java/awt/KeyboardFocusManager.html#upFocusCycle%28java.awt.Component%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
aComponent
- the Component that is the basis for the focus traversal operation
See Also:
Component.transferFocusUpCycle()
downFocusCycle
public void downFocusCycle(Container aContainer)
Moves the focus down one focus traversal cycle. If aContainer is a focus cycle root, then the focus owner is set to aContainer's default Component to focus, and the current focus cycle root is set to aContainer. If aContainer is not a focus cycle root, then no focus traversal operation occurs.
Specified by:
[downFocusCycle](../../java/awt/KeyboardFocusManager.html#downFocusCycle%28java.awt.Container%29)
in class [KeyboardFocusManager](../../java/awt/KeyboardFocusManager.html "class in java.awt")
Parameters:
aContainer
- the Container that is the basis for the focus traversal operation
See Also:
Container.transferFocusDownCycle()
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.