The KeyboardFocusManager is both a centralized location for client code to query for the focus owner and initiate focus changes, and an event dispatcher for all FocusEvents, WindowEvents related to focus, and KeyEvents.
Please see How to Use the Focus Subsystem, a section in The Java Tutorial, and the Focus Specification for more information.
Window, Frame, Dialog, java.awt.event.FocusEvent , java.awt.event.WindowEvent , java.awt.event.KeyEvent
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static Window | activeWindow
Only a Frame or a Dialog can be the active Window. |
| private static boolean | |
| public static final int | BACKWARD_TRAVERSAL_KEYS
The identifier for the Backward focus traversal keys. |
| private PropertyChangeSupport | changeSupport
A description of any PropertyChangeListeners which have been registered. |
| private static boolean | |
| private static Container | currentFocusCycleRoot
The current focus cycle root. |
| private static LinkedList | |
| pack-priv transient SequencedEvent | |
| private static final String[] | defaultFocusTraversalKeyPropertyNames
The bound property names of each focus traversal key. |
| private Set | defaultFocusTraversalKeys
The default focus traversal keys. |
| private FocusTraversalPolicy | defaultPolicy
The default FocusTraversalPolicy for all Windows that have no policy of their own set. |
| private static volatile boolean | |
| public static final int | DOWN_CYCLE_TRAVERSAL_KEYS
The identifier for the Down Cycle focus traversal keys. |
| private static Window | focusedWindow
The Window which is, or contains, the focus owner. |
| private static final PlatformLogger | |
| private static Component | focusOwner
The Component in an application that will typically receive all KeyEvents generated by the user. |
| public static final int | FORWARD_TRAVERSAL_KEYS
The identifier for the Forward focus traversal keys. |
| private static LinkedList | |
| private LinkedList | keyEventDispatchers
This KeyboardFocusManager's KeyEventDispatcher chain. |
| private LinkedList | keyEventPostProcessors
This KeyboardFocusManager's KeyEventPostProcessor chain. |
| private static final PlatformLogger | |
| private static KeyboardFocusManager | |
| private static Map | mostRecentFocusOwners
Maps Windows to those Windows' most recent focus owners. |
| private static Component | |
| pack-priv transient KeyboardFocusManagerPeer | |
| private static Component | permanentFocusOwner
The Component in an application that will regain focus when an outstanding temporary focus transfer has completed, or the focus owner, if no outstanding temporary transfer exists. |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| public static final int | UP_CYCLE_TRAVERSAL_KEYS
The identifier for the Up Cycle focus traversal keys. |
| private VetoableChangeSupport | vetoableSupport
A description of any VetoableChangeListeners which have been registered. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | addKeyEventDispatcher(KeyEventDispatcher
the KeyEventDispatcher to add to the dispatcher chain dispatcher)Adds a KeyEventDispatcher to this KeyboardFocusManager's dispatcher chain. |
| public void | addKeyEventPostProcessor(KeyEventPostProcessor
the KeyEventPostProcessor to add to the post-processor
chain processor)Adds a KeyEventPostProcessor to this KeyboardFocusManager's post- processor chain. |
| public void | addPropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be added listener)Adds a PropertyChangeListener to the listener list. |
| public void | addPropertyChangeListener(String
one of the property names listed above propertyName, PropertyChangeListener the PropertyChangeListener to be added listener)Adds a PropertyChangeListener to the listener list for a specific property. |
| public void | addVetoableChangeListener(VetoableChangeListener
the VetoableChangeListener to be added listener)Adds a VetoableChangeListener to the listener list. |
| public void | addVetoableChangeListener(String
one of the property names listed above propertyName, VetoableChangeListener the VetoableChangeListener to be added listener)Adds a VetoableChangeListener to the listener list for a specific property. |
| public void | clearFocusOwner()
Clears the focus owner at both the Java and native levels if the focus owner exists and resides in the same context as the calling thread, otherwise the method returns silently. |
| public void | |
| pack-priv void | |
| pack-priv void | |
| pack-priv static void | |
| protected abstract void | dequeueKeyEvents(long
the timestamp specified in the call to
after, Component enqueueKeyEvents, or any value < 0the Component specified in the call to
untilFocused)enqueueKeyEventsCalled by the AWT to notify the KeyboardFocusManager that it should cancel delayed dispatching of KeyEvents. |
| protected abstract void | discardKeyEvents(Component
the Component specified in one or more calls to
comp)enqueueKeyEventsCalled by the AWT to notify the KeyboardFocusManager that it should cancel delayed dispatching of KeyEvents. |
| private static Throwable | |
| public abstract boolean | Returns: true if this method dispatched the event;
false otherwisethe AWTEvent to be dispatched e)This method is called by the AWT event dispatcher requesting that the current KeyboardFocusManager dispatch the specified event on its behalf. |
| public abstract boolean | Returns: true if the KeyEvent was dispatched;
false otherwisethe KeyEvent which the current KeyboardFocusManager has
requested that this KeyEventDispatcher dispatch e)Redeclares java. Typically this method will be called by |
| public abstract void | downFocusCycle(Container
the Container that is the basis for the focus
traversal operation aContainer)Moves the focus down one focus traversal cycle. |
| public final void | downFocusCycle()
Moves the focus down one focus traversal cycle from the current focus owner, if and only if the current focus owner is a Container that is a focus cycle root. |
| pack-priv void | |
| protected abstract void | enqueueKeyEvents(long
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 after, Component Component which should receive a FOCUS_GAINED event
before any pending KeyEvents untilFocused)Called by the AWT to notify the KeyboardFocusManager that it should delay dispatching of KeyEvents until the specified Component becomes the focus owner. |
| protected void | firePropertyChange(String
the name of the property that has changed propertyName, Object the property's previous value oldValue, Object the property's new value newValue)Fires a PropertyChangeEvent in response to a change in a bound property. |
| protected void | fireVetoableChange(String
the name of the property that has changed propertyName, Object the property's previous value oldValue, Object the property's new value newValue)Fires a PropertyChangeEvent in response to a change in a vetoable property. |
| private static boolean | |
| public abstract void | focusNextComponent(Component
the Component that is the basis for the focus
traversal operation aComponent)Focuses the Component after aComponent, typically based on a FocusTraversalPolicy. |
| public final void | |
| public abstract void | focusPreviousComponent(Component
the Component that is the basis for the focus
traversal operation aComponent)Focuses the Component before aComponent, typically based on a FocusTraversalPolicy. |
| public final void | |
| public Window | |
| public Container | Returns: the current focus cycle root, or null if the current focus cycle root is not a member of the calling thread's contextReturns the current focus cycle root, if the current focus cycle root is in the same context as the calling thread. |
| public static synchronized KeyboardFocusManager | Returns: the current KeyboardFocusManagerReturns the current KeyboardFocusManager instance |
| pack-priv final SequencedEvent | |
| pack-priv Component | |
| public Set | Returns: theSet of AWTKeyStrokes
for the specified operation; the Set
will be unmodifiable, and may be empty; null
will never be returnedone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS id)Returns a Set of default focus traversal keys for a given traversal operation. |
| public synchronized FocusTraversalPolicy | Returns: the default FocusTraversalPolicy. null will never be returned.Returns the default FocusTraversalPolicy. |
| private static KeyboardFocusManager. | |
| public Window | |
| public Component | Returns: the focus owner, or null if the focus owner is not a member of the calling thread's contextReturns the focus owner, if the focus owner is in the same context as the calling thread. |
| protected Window | Returns: the active WindowReturns the active Window, even if the calling thread is in a different context than the active Window. |
| protected Container | Returns: the current focus cycle root, or null if the current focus cycle root is not a member of the calling thread's contextReturns the current focus cycle root, even if the calling thread is in a different context than the current focus cycle root. |
| protected Window | Returns: the focused WindowReturns the focused Window, even if the calling thread is in a different context than the focused Window. |
| protected Component | Returns: the focus ownerReturns the focus owner, even if the calling thread is in a different context than the focus owner. |
| protected Component | Returns: the permanent focus owner, or null if there is noneReturns the permanent focus owner. |
| pack-priv static Component | |
| protected synchronized List | Returns: a possibly null or empty List of KeyEventDispatchersReturns this KeyboardFocusManager's KeyEventDispatcher chain as a List. |
| protected List | Returns: a possibly null or empty List of KeyEventPostProcessorsReturns this KeyboardFocusManager's KeyEventPostProcessor chain as a List. |
| private static KeyboardFocusManager. | |
| pack-priv static synchronized Component | |
| pack-priv Window | |
| pack-priv Component | |
| public Component | Returns: the permanent focus owner, or null if there is noneReturns the permanent focus owner. |
| public synchronized PropertyChangeListener[] | Returns: all of this keyboard focus manager'sPropertyChangeListeners
or an empty array if no property change
listeners are currently registeredReturns an array of all the property change listeners registered on this keyboard focus manager. |
| public synchronized PropertyChangeListener[] | Returns: all of thePropertyChangeListeners associated with
the named property or an empty array if no such listeners have
been added.the property name propertyName)Returns an array of all the |
| public synchronized VetoableChangeListener[] | Returns: all of this keyboard focus manager'sVetoableChangeListeners
or an empty array if no vetoable change
listeners are currently registeredReturns an array of all the vetoable change listeners registered on this keyboard focus manager. |
| public synchronized VetoableChangeListener[] | Returns: all of theVetoableChangeListeners associated with
the named property or an empty array if no such listeners have
been added.the property name propertyName)Returns an array of all the |
| private static void | |
| pack-priv static Set | |
| private void | |
| pack-priv static boolean | |
| pack-priv static boolean | |
| pack-priv static boolean | |
| private static boolean | |
| private static boolean | |
| pack-priv static Window | markClearGlobalFocusOwner()
Returns the Window which will be active after processing this request, or null if this is a duplicate request. |
| public abstract boolean | Returns: true to indicate that no other
KeyEventPostProcessor will be notified of the KeyEvent.the KeyEvent to post-process e)Redeclares java. This method will be called by |
| pack-priv static void | |
| public abstract void | processKeyEvent(Component
the Component that will be the basis for a focus
traversal operation if the specified event represents a focus
traversal key for the Component focusedComponent, KeyEvent the event that may represent a focus traversal key e)This method initiates a focus traversal operation if and only if the KeyEvent represents a focus traversal key for the specified focusedComponent. |
| pack-priv static boolean | processSynchronousLightweightTransfer(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time)
|
| public final void | redispatchEvent(Component
the Component to which the event should be dispatched target, AWTEvent the event to dispatch e)Redispatches an AWTEvent in such a way that the AWT event dispatcher will not recursively request that the KeyboardFocusManager, or any installed KeyEventDispatchers, dispatch the event again. |
| pack-priv static boolean | |
| public void | removeKeyEventDispatcher(KeyEventDispatcher
the KeyEventDispatcher to remove from the dispatcher
chain dispatcher)Removes a KeyEventDispatcher which was previously added to this KeyboardFocusManager's dispatcher chain. |
| public void | removeKeyEventPostProcessor(KeyEventPostProcessor
the KeyEventPostProcessor to remove from the post-
processor chain processor)Removes a previously added KeyEventPostProcessor from this KeyboardFocusManager's post-processor chain. |
| pack-priv static void | |
| public void | removePropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be removed listener)Removes a PropertyChangeListener from the listener list. |
| public void | removePropertyChangeListener(String
a valid property name propertyName, PropertyChangeListener the PropertyChangeListener to be removed listener)Removes a PropertyChangeListener from the listener list for a specific property. |
| public void | removeVetoableChangeListener(VetoableChangeListener
the VetoableChangeListener to be removed listener)Removes a VetoableChangeListener from the listener list. |
| public void | removeVetoableChangeListener(String
a valid property name propertyName, VetoableChangeListener the VetoableChangeListener to be removed listener)Removes a VetoableChangeListener from the listener list for a specific property. |
| pack-priv static AWTEvent | |
| pack-priv static FocusEvent | |
| pack-priv static FocusEvent | |
| pack-priv static FocusEvent | |
| public static void | setCurrentKeyboardFocusManager(KeyboardFocusManager
the new KeyboardFocusManager newManager)Sets the current KeyboardFocusManager instance. |
| pack-priv final void | |
| public void | setDefaultFocusTraversalKeys(int
one of
id, Set<? extends AWTKeyStroke> KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYSthe Set of keystrokes)AWTKeyStrokes for the
specified operationSets the default focus traversal keys for a given traversal operation. |
| public void | setDefaultFocusTraversalPolicy(FocusTraversalPolicy
the new, default FocusTraversalPolicy defaultPolicy)Sets the default FocusTraversalPolicy. |
| protected void | |
| public void | setGlobalCurrentFocusCycleRoot(Container
the new focus cycle root newFocusCycleRoot)Sets the current focus cycle root. |
| pack-priv void | |
| protected void | |
| protected void | |
| protected void | setGlobalPermanentFocusOwner(Component
the permanent focus owner permanentFocusOwner)Sets the permanent focus owner. |
| pack-priv static void | |
| pack-priv static synchronized void | |
| pack-priv void | |
| pack-priv static int | shouldNativelyFocusHeavyweight(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time, FocusEvent.
Indicates whether the native implementation should proceed with a pending, native focus request. |
| public abstract void | upFocusCycle(Component
the Component that is the basis for the focus
traversal operation aComponent)Moves the focus up one focus traversal cycle. |
| public final void |