java.lang.Object | +--java.awt.KeyboardFocusManager
Safe: The KeyboardFocusManager is responsible for managing the active and focused Windows, and the current focus owner. The focus owner is defined as the Component in an application that will typically receive all KeyEvents generated by the user. The focused Window is the Window that is, or contains, the focus owner. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.
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.
Some browsers partition applets in different code bases into separate contexts, and establish walls between these contexts. In such a scenario, there will be one KeyboardFocusManager per context. Other browsers place all applets into the same context, implying that there will be only a single, global KeyboardFocusManager for all applets. This behavior is implementation-dependent. Consult your browser's documentation for more information. No matter how many contexts there may be, however, there can never be more than one focus owner, focused Window, or active Window, per ClassLoader.
Window
,
Frame
,
Dialog
,
java.awt.event.FocusEvent
,
java.awt.event.WindowEvent
,
java.awt.event.KeyEvent
private java.beans.PropertyChangeSupport
changeSupport
private static String[]
defaultFocusTraversalKeyPropertyNames
private static String[]
defaultFocusTraversalKeyStrings
private FocusTraversalPolicy
defaultPolicy
static int
DOWN_CYCLE_TRAVERSAL_KEYS
private static Component
focusOwner
private static Component
permanentFocusOwner
private static AWTPermission
replaceKeyboardFocusManagerPermission
private java.beans.VetoableChangeSupport
vetoableSupport
KeyboardFocusManager()
void
addKeyEventDispatcher(KeyEventDispatcher dispatcher)
void
addKeyEventPostProcessor(KeyEventPostProcessor processor)
void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
void
addPropertyChangeListener(String propertyName,
java.beans.PropertyChangeListener listener)
void
addVetoableChangeListener(String propertyName,
java.beans.VetoableChangeListener listener)
void
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
void
clearGlobalFocusOwner()
protected abstract void
dequeueKeyEvents(long after,
Component untilFocused)
protected abstract void
discardKeyEvents(Component comp)
abstract boolean
dispatchEvent(AWTEvent e)
abstract boolean
dispatchKeyEvent(KeyEvent e)
dispatchEvent
if no
other KeyEventDispatcher in the dispatcher chain dispatched the
KeyEvent, or if no other KeyEventDispatchers are registered.
void
downFocusCycle()
abstract void
downFocusCycle(Container aContainer)
protected abstract void
enqueueKeyEvents(long after,
Component untilFocused)
protected void
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
protected void
fireVetoableChange(String propertyName,
Object oldValue,
Object newValue)
abstract void
focusNextComponent(Component aComponent)
abstract void
focusPreviousComponent(Component aComponent)
Window
getActiveWindow()
Container
getCurrentFocusCycleRoot()
static KeyboardFocusManager
getCurrentKeyboardFocusManager()
(package private) static KeyboardFocusManager
getCurrentKeyboardFocusManager(sun.awt.AppContext appcontext)
Set
getDefaultFocusTraversalKeys(int id)
FocusTraversalPolicy
getDefaultFocusTraversalPolicy()
Window
getFocusedWindow()
Component
getFocusOwner()
protected Window
getGlobalActiveWindow()
protected Container
getGlobalCurrentFocusCycleRoot()
protected Window
getGlobalFocusedWindow()
protected Component
getGlobalFocusOwner()
protected Component
getGlobalPermanentFocusOwner()
protected List
getKeyEventDispatchers()
protected List
getKeyEventPostProcessors()
Component
getPermanentFocusOwner()
java.beans.PropertyChangeListener[]
getPropertyChangeListeners()
java.beans.PropertyChangeListener[]
getPropertyChangeListeners(String propertyName)
PropertyChangeListener
s
associated with the named property.
java.beans.VetoableChangeListener[]
getVetoableChangeListeners()
java.beans.VetoableChangeListener[]
getVetoableChangeListeners(String propertyName)
VetoableChangeListener
s
associated with the named property.
(package private) static void
heavyweightButtonDown(Component heavyweight,
long time,
boolean acceptDuplicates)
(package private) static Set
loadFocusTraversalKeys(String propName,
String defaultValue,
Set targetSet)
(package private) static Window
markClearGlobalFocusOwner()
abstract boolean
postProcessKeyEvent(KeyEvent e)
dispatchKeyEvent
.
abstract void
processKeyEvent(Component focusedComponent,
KeyEvent e)
(package private) static boolean
processSynchronousLightweightTransfer(Component heavyweight,
Component descendant,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time)
void
redispatchEvent(Component target,
AWTEvent e)
void
removeKeyEventDispatcher(KeyEventDispatcher dispatcher)
void
removeKeyEventPostProcessor(KeyEventPostProcessor processor)
void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
void
removePropertyChangeListener(String propertyName,
java.beans.PropertyChangeListener listener)
void
removeVetoableChangeListener(String propertyName,
java.beans.VetoableChangeListener listener)
void
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
static void
setCurrentKeyboardFocusManager(KeyboardFocusManager newManager)
void
setDefaultFocusTraversalKeys(int id,
Set keystrokes)
void
setDefaultFocusTraversalPolicy(FocusTraversalPolicy defaultPolicy)
void
setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot)
protected void
setGlobalPermanentFocusOwner(Component permanentFocusOwner)
(package private) static int
shouldNativelyFocusHeavyweight(Component heavyweight,
Component descendant,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time)
void
upFocusCycle()
abstract void
upFocusCycle(Component aComponent)
private static final sun.awt.DebugHelper dbg
public static final int FORWARD_TRAVERSAL_KEYS
public static final int BACKWARD_TRAVERSAL_KEYS
public static final int UP_CYCLE_TRAVERSAL_KEYS
public static final int DOWN_CYCLE_TRAVERSAL_KEYS
static final int TRAVERSAL_KEY_LENGTH
private static Component focusOwner
private static Component permanentFocusOwner
private static Window focusedWindow
private static Window activeWindow
private FocusTraversalPolicy defaultPolicy
private static final String[] defaultFocusTraversalKeyPropertyNames
private static final String[] defaultFocusTraversalKeyStrings
private Set[] defaultFocusTraversalKeys
private static Container currentFocusCycleRoot
private java.beans.VetoableChangeSupport vetoableSupport
private java.beans.PropertyChangeSupport changeSupport
private LinkedList keyEventDispatchers
addKeyEventDispatcher
. If no other
KeyEventDispatchers are registered, this field may be null or refer to
a List of length 0.
private LinkedList keyEventPostProcessors
addKeyEventPostProcessor
.
If no other KeyEventPostProcessors are registered, this field may be
null or refer to a List of length 0.
private static Map mostRecentFocusOwners
private static final String notPrivileged
private static AWTPermission replaceKeyboardFocusManagerPermission
private static LinkedList heavyweightRequests
private static LinkedList currentLightweightRequests
private static boolean clearingCurrentLightweightRequests
private static Component newFocusOwner
static final int SNFH_FAILURE
static final int SNFH_SUCCESS_HANDLED
static final int SNFH_SUCCESS_PROCEED
public KeyboardFocusManager()
private static void initIDs()
public static KeyboardFocusManager getCurrentKeyboardFocusManager()
setCurrentKeyboardFocusManager(java.awt.KeyboardFocusManager)
static KeyboardFocusManager getCurrentKeyboardFocusManager(sun.awt.AppContext appcontext)
public static void setCurrentKeyboardFocusManager(KeyboardFocusManager newManager) throws SecurityException
If a SecurityManager is installed, the calling thread must be granted the AWTPermission "replaceKeyboardFocusManager" in order to replace the the current KeyboardFocusManager. If this permission is not granted, this method will throw a SecurityException, and the current KeyboardFocusManager will be unchanged.
newManager
- the new KeyboardFocusManager for this thread's context
SecurityException
- if the calling thread does not have permission
to replace the current KeyboardFocusManagergetCurrentKeyboardFocusManager()
,
DefaultKeyboardFocusManager
static Set loadFocusTraversalKeys(String propName, String defaultValue, Set targetSet)
public Component getFocusOwner()
getGlobalFocusOwner()
,
setGlobalFocusOwner(java.awt.Component)
protected Component getGlobalFocusOwner() throws SecurityException
This method will throw a SecurityException if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context.
SecurityException
- if this KeyboardFocusManager is not the
current KeyboardFocusManager for the calling thread's contextgetFocusOwner()
,
setGlobalFocusOwner(java.awt.Component)
protected void setGlobalFocusOwner(Component focusOwner)
This method does not actually set the focus to the specified Component.
It merely stores the value to be subsequently returned by
getFocusOwner()
. Use Component.requestFocus()
or Component.requestFocusInWindow()
to change the focus
owner, subject to platform limitations.
focusOwner
- the focus ownergetFocusOwner()
,
getGlobalFocusOwner()
,
Component.requestFocus()
,
Component.requestFocusInWindow()
,
Component.isFocusable()
public void clearGlobalFocusOwner()
requestFocus()
. This operation
does not change the focused or active Windows.
Component.requestFocus()
,
java.awt.event.FocusEvent#FOCUS_LOST
private void _clearGlobalFocusOwner()
static Component getNativeFocusOwner()
static Window getNativeFocusedWindow()
public Component getPermanentFocusOwner()
getGlobalPermanentFocusOwner()
,
setGlobalPermanentFocusOwner(java.awt.Component)
protected Component getGlobalPermanentFocusOwner() throws SecurityException
This method will throw a SecurityException if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context.
SecurityException
- if this KeyboardFocusManager is not the
current KeyboardFocusManager for the calling thread's contextgetPermanentFocusOwner()
,
setGlobalPermanentFocusOwner(java.awt.Component)
protected void setGlobalPermanentFocusOwner(Component permanentFocusOwner)
This method does not actually set the focus to the specified Component.
It merely stores the value to be subsequently returned by
getPermanentFocusOwner()
. Use
Component.requestFocus()
or
Component.requestFocusInWindow()
to change the focus owner,
subject to platform limitations.
permanentFocusOwner
- the permanent focus ownergetPermanentFocusOwner()
,
getGlobalPermanentFocusOwner()
,
Component.requestFocus()
,
Component.requestFocusInWindow()
,
Component.isFocusable()
public Window getFocusedWindow()
getGlobalFocusedWindow()
,
setGlobalFocusedWindow(java.awt.Window)
protected Window getGlobalFocusedWindow() throws SecurityException
This method will throw a SecurityException if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context.
SecurityException
- if this KeyboardFocusManager is not the
current KeyboardFocusManager for the calling thread's contextgetFocusedWindow()
,
setGlobalFocusedWindow(java.awt.Window)
protected void setGlobalFocusedWindow(Window focusedWindow)
This method does not actually change the focused Window as far as the
native windowing system is concerned. It merely stores the value to be
subsequently returned by getFocusedWindow()
. Use
Component.requestFocus()
or
Component.requestFocusInWindow()
to change the focused
Window, subject to platform limitations.
focusedWindow
- the focused WindowgetFocusedWindow()
,
getGlobalFocusedWindow()
,
Component.requestFocus()
,
Component.requestFocusInWindow()
,
Window.isFocusableWindow()
public Window getActiveWindow()
getGlobalActiveWindow()
,
setGlobalActiveWindow(java.awt.Window)
protected Window getGlobalActiveWindow() throws SecurityException
This method will throw a SecurityException if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context.
SecurityException
- if this KeyboardFocusManager is not the
current KeyboardFocusManager for the calling thread's contextgetActiveWindow()
,
setGlobalActiveWindow(java.awt.Window)
protected void setGlobalActiveWindow(Window activeWindow)
This method does not actually change the active Window as far as the
native windowing system is concerned. It merely stores the value to be
subsequently returned by getActiveWindow()
. Use
Component.requestFocus()
or
Component.requestFocusInWindow()
to change the active
Window, subject to platform limitations.
activeWindow
- the active WindowgetActiveWindow()
,
getGlobalActiveWindow()
,
Component.requestFocus()
,
Component.requestFocusInWindow()
public FocusTraversalPolicy getDefaultFocusTraversalPolicy()
setDefaultFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalPolicy(FocusTraversalPolicy defaultPolicy)
defaultPolicy
- the new, default FocusTraversalPolicy
IllegalArgumentException
- if defaultPolicy is nullgetDefaultFocusTraversalPolicy()
,
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalKeys(int id, Set keystrokes)
Set
will be in effect on all
Window
s that have no such Set
of
their own explicitly defined. This Set
will also be
inherited, recursively, by any child Component
of
those Windows
that has
no such Set
of its own explicitly defined.
The default values for the default focus traversal keys are implementation-dependent. Sun recommends that all implementations for a particular native platform use the same default values. The recommendations for Windows and Unix are listed below. These recommendations are used in the Sun AWT implementations.
Identifier | Meaning | Default |
---|---|---|
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS |
Normal forward keyboard traversal | TAB on KEY_PRESSED ,
CTRL-TAB on KEY_PRESSED |
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS |
Normal reverse keyboard traversal | SHIFT-TAB on KEY_PRESSED ,
CTRL-SHIFT-TAB on KEY_PRESSED |
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS |
Go up one focus traversal cycle | none |
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS |
Go down one focus traversal cycle | none |
Set
;
Collections.EMPTY_SET
is recommended.
Using the AWTKeyStroke
API, client code can
specify on which of two
specific KeyEvent
s, KEY_PRESSED
or
KEY_RELEASED
, the focus traversal operation will
occur. Regardless of which KeyEvent
is specified,
however, all KeyEvent
s related to the focus
traversal key, including the associated KEY_TYPED
event, will be consumed, and will not be dispatched
to any Component
. It is a runtime error to
specify a KEY_TYPED
event as
mapping to a focus traversal operation, or to map the same event to
multiple default focus traversal operations.
id
- one of
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
keystrokes
- the Set of AWTKeyStroke
s for the
specified operation
IllegalArgumentException
- if id is not one of
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
,
or if keystrokes is null
,
or if keystrokes contains null
,
or if any Object
in
keystrokes is not an AWTKeyStroke
,
or if any keystroke
represents a KEY_TYPED
event,
or if any keystroke already maps
to another default focus traversal operationgetDefaultFocusTraversalKeys(int)
,
Component.setFocusTraversalKeys(int, java.util.Set)
,
Component.getFocusTraversalKeys(int)
public Set getDefaultFocusTraversalKeys(int id)
setDefaultFocusTraversalKeys
for a full description of each
operation.)
id
- one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Set
of AWTKeyStroke
s
for the specified operation; the Set
will be unmodifiable, and may be empty; null
will never be returned
IllegalArgumentException
- if id is not one of
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYSsetDefaultFocusTraversalKeys(int, java.util.Set)
,
Component.setFocusTraversalKeys(int, java.util.Set)
,
Component.getFocusTraversalKeys(int)
public Container getCurrentFocusCycleRoot()
This method is intended to be used only by KeyboardFocusManagers and focus implementations. It is not for general client use.
getGlobalCurrentFocusCycleRoot()
,
setGlobalCurrentFocusCycleRoot(java.awt.Container)
protected Container getGlobalCurrentFocusCycleRoot() throws SecurityException
This method will throw a SecurityException if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context.
SecurityException
- if this KeyboardFocusManager is not the
current KeyboardFocusManager for the calling thread's contextgetCurrentFocusCycleRoot()
,
setGlobalCurrentFocusCycleRoot(java.awt.Container)
public void setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot)
This method is intended to be used only by KeyboardFocusManagers and focus implementations. It is not for general client use.
newFocusCycleRoot
- the new focus cycle rootgetCurrentFocusCycleRoot()
,
getGlobalCurrentFocusCycleRoot()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the PropertyChangeListener to be addedremovePropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners()
,
addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
listener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners()
,
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener
s
or an empty array if no property change
listeners are currently registeredaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
public void addPropertyChangeListener(String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be addedaddPropertyChangeListener(java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
public void removePropertyChangeListener(String propertyName, java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
getPropertyChangeListeners(java.lang.String)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
PropertyChangeListener
s
associated with the named property.
PropertyChangeListener
s associated with
the named property or an empty array if no such listeners have
been added.addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- the name of the property that has changedoldValue
- the property's previous valuenewValue
- the property's new valuepublic void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- the VetoableChangeListener to be addedremoveVetoableChangeListener(java.beans.VetoableChangeListener)
,
getVetoableChangeListeners()
,
addVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
listener
- the VetoableChangeListener to be removedaddVetoableChangeListener(java.beans.VetoableChangeListener)
,
getVetoableChangeListeners()
,
removeVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public java.beans.VetoableChangeListener[] getVetoableChangeListeners()
VetoableChangeListener
s
or an empty array if no vetoable change
listeners are currently registeredaddVetoableChangeListener(java.beans.VetoableChangeListener)
,
removeVetoableChangeListener(java.beans.VetoableChangeListener)
,
getVetoableChangeListeners(java.lang.String)
public void addVetoableChangeListener(String propertyName, java.beans.VetoableChangeListener listener)
propertyName
- one of the property names listed abovelistener
- the VetoableChangeListener to be addedaddVetoableChangeListener(java.beans.VetoableChangeListener)
,
removeVetoableChangeListener(java.beans.VetoableChangeListener)
,
getVetoableChangeListeners()
public void removeVetoableChangeListener(String propertyName, java.beans.VetoableChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
propertyName
- a valid property namelistener
- the VetoableChangeListener to be removedaddVetoableChangeListener(java.beans.VetoableChangeListener)
,
getVetoableChangeListeners()
,
removeVetoableChangeListener(java.beans.VetoableChangeListener)
public java.beans.VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
VetoableChangeListener
s
associated with the named property.
VetoableChangeListener
s associated with
the named property or an empty array if no such listeners have
been added.addVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
,
removeVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
,
getVetoableChangeListeners()
protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws java.beans.PropertyVetoException
propertyName
- the name of the property that has changedoldValue
- the property's previous valuenewValue
- the property's new value
java.beans.PropertyVetoException
- if a
VetoableChangeListener
threw
PropertyVetoException
public void addKeyEventDispatcher(KeyEventDispatcher dispatcher)
true
from its
dispatchKeyEvent
method. There is no limit to the total
number of KeyEventDispatchers which can be added, nor to the number of
times which a particular KeyEventDispatcher instance can be added.
If a null dispatcher is specified, no action is taken and no exception is thrown.
dispatcher
- the KeyEventDispatcher to add to the dispatcher chainremoveKeyEventDispatcher(java.awt.KeyEventDispatcher)
public void removeKeyEventDispatcher(KeyEventDispatcher dispatcher)
addKeyEventDispatcher
.
If a null dispatcher is specified, if the specified dispatcher is not in the dispatcher chain, or if this KeyboardFocusManager is specified without having been explicitly re-registered, no action is taken and no exception is thrown.
dispatcher
- the KeyEventDispatcher to remove from the dispatcher
chainaddKeyEventDispatcher(java.awt.KeyEventDispatcher)
protected List getKeyEventDispatchers()
addKeyEventDispatcher
. If no other KeyEventDispatchers are
registered, implementations are free to return null or a List of length
0. Client code should not assume one behavior over another, nor should
it assume that the behavior, once established, will not change.
addKeyEventDispatcher(java.awt.KeyEventDispatcher)
,
removeKeyEventDispatcher(java.awt.KeyEventDispatcher)
public void addKeyEventPostProcessor(KeyEventPostProcessor processor)
true
from its
postProcessKeyEvent
method. There is no limit to the the
total number of KeyEventPostProcessors that can be added, nor to the
number of times that a particular KeyEventPostProcessor instance can be
added.
If a null post-processor is specified, no action is taken and no exception is thrown.
processor
- the KeyEventPostProcessor to add to the post-processor
chainremoveKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
public void removeKeyEventPostProcessor(KeyEventPostProcessor processor)
addKeyEventPostProcessor
can be
removed.
If a null post-processor is specified, if the specified post-processor is not in the post-processor chain, or if this KeyboardFocusManager is specified without having been explicitly added, no action is taken and no exception is thrown.
processor
- the KeyEventPostProcessor to remove from the post-
processor chainaddKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
protected List getKeyEventPostProcessors()
addKeyEventPostProcessor
. If
no KeyEventPostProcessors are registered, implementations are free to
return null or a List of length 0. Client code should not assume one
behavior over another, nor should it assume that the behavior, once
established, will not change.
addKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
,
removeKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
static void setMostRecentFocusOwner(Component component)
static void setMostRecentFocusOwner(Window window, Component component)
static void clearMostRecentFocusOwner(Component comp)
static Component getMostRecentFocusOwner(Window window)
public abstract boolean dispatchEvent(AWTEvent e)
redispatchEvent
to prevent the AWT event
dispatcher from recursively requesting that the KeyboardFocusManager
dispatch the event again. If this method returns false
,
then the AWT event dispatcher will attempt to dispatch the event itself.
e
- the AWTEvent to be dispatched
true
if this method dispatched the event;
false
otherwiseredispatchEvent(java.awt.Component, java.awt.AWTEvent)
,
dispatchKeyEvent(java.awt.event.KeyEvent)
public final void redispatchEvent(Component target, AWTEvent e)
dispatchEvent
and client-defined
KeyEventDispatchers must call redispatchEvent(target, e)
instead of target.dispatchEvent(e)
to dispatch an event.
This method is intended to be used only by KeyboardFocusManagers and KeyEventDispatchers. It is not for general client use.
target
- the Component to which the event should be dispatchede
- the event to dispatchdispatchEvent(java.awt.AWTEvent)
,
KeyEventDispatcher
public abstract boolean dispatchKeyEvent(KeyEvent e)
dispatchEvent
if no
other KeyEventDispatcher in the dispatcher chain dispatched the
KeyEvent, or if no other KeyEventDispatchers are registered. If an
implementation of this method returns false
,
dispatchEvent
may try to dispatch the KeyEvent itself, or
may simply return false
. If true
is returned,
dispatchEvent
should return true
as well.
dispatchKeyEvent
in interface KeyEventDispatcher
e
- the KeyEvent which the current KeyboardFocusManager has
requested that this KeyEventDispatcher dispatch
true
if the KeyEvent was dispatched;
false
otherwisedispatchEvent(java.awt.AWTEvent)
public abstract boolean postProcessKeyEvent(KeyEvent e)
dispatchKeyEvent
.
By default, this method will handle any unconsumed KeyEvents that
map to an AWT MenuShortcut
by consuming the event
and activating the shortcut.
postProcessKeyEvent
in interface KeyEventPostProcessor
e
- the KeyEvent to post-process
true
to indicate that no other
KeyEventPostProcessor will be notified of the KeyEvent.dispatchKeyEvent(java.awt.event.KeyEvent)
,
MenuShortcut
public abstract void processKeyEvent(Component focusedComponent, KeyEvent e)
focusedComponent
- the Component that will be the basis for a focus
traversal operation if the specified event represents a focus
traversal key for the Componente
- the event that may represent a focus traversal keyprotected abstract void enqueueKeyEvents(long after, Component untilFocused)
dequeueKeyEvents
or
discardKeyEvents
.
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 handleduntilFocused
- Component which should receive a FOCUS_GAINED event
before any pending KeyEventsdequeueKeyEvents(long, java.awt.Component)
,
discardKeyEvents(java.awt.Component)
protected abstract void dequeueKeyEvents(long after, Component untilFocused)
enqueueKeyEvents
with the
same timestamp and Component should be released for normal dispatching
to the current focus owner. 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.
after
- the timestamp specified in the call to
enqueueKeyEvents
, or any value < 0untilFocused
- the Component specified in the call to
enqueueKeyEvents
enqueueKeyEvents(long, java.awt.Component)
,
discardKeyEvents(java.awt.Component)
protected abstract void discardKeyEvents(Component comp)
enqueueKeyEvents
with the same Component should be discarded.
comp
- the Component specified in one or more calls to
enqueueKeyEvents
enqueueKeyEvents(long, java.awt.Component)
,
dequeueKeyEvents(long, java.awt.Component)
public abstract void focusNextComponent(Component aComponent)
aComponent
- the Component that is the basis for the focus
traversal operationFocusTraversalPolicy
public abstract void focusPreviousComponent(Component aComponent)
aComponent
- the Component that is the basis for the focus
traversal operationFocusTraversalPolicy
public abstract void upFocusCycle(Component aComponent)
aComponent
- the Component that is the basis for the focus
traversal operationpublic abstract void downFocusCycle(Container aContainer)
public final void focusNextComponent()
public final void focusPreviousComponent()
public final void upFocusCycle()
public final void downFocusCycle()
int requestCount()
static boolean processSynchronousLightweightTransfer(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time)
static int shouldNativelyFocusHeavyweight(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time)
static void heavyweightButtonDown(Component heavyweight, long time)
static void heavyweightButtonDown(Component heavyweight, long time, boolean acceptDuplicates)
static Window markClearGlobalFocusOwner()
Component getCurrentWaitingRequest(Component parent)
static AWTEvent retargetFocusEvent(AWTEvent event)
static boolean removeFirstRequest()
static void removeLastFocusRequest(Component heavyweight)
static void removeFocusRequest(Component component)
private static void clearFocusRequestList()
private static boolean focusedWindowChanged(Component a, Component b)
private static Window getContainingWindow(Component comp)
private static Component getHeavyweight(Component comp)
private static boolean isProxyActiveImpl(KeyEvent e)
static boolean isProxyActive(KeyEvent e)