|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.KeyboardFocusManager java.awt.DefaultKeyboardFocusManager javax.swing.FocusManager javax.swing.DefaultFocusManager javax.swing.DelegatingDefaultFocusManager
Provides a javax.swing.DefaultFocusManager view onto an arbitrary java.awt.KeyboardFocusManager. We subclass DefaultFocusManager instead of FocusManager because it seems more backward-compatible. It is likely that some pre-1.4 code assumes that the object returned by FocusManager.getCurrentManager is an instance of DefaultFocusManager unless set explicitly.
Nested Class Summary |
Nested classes inherited from class java.awt.DefaultKeyboardFocusManager |
|
Nested classes inherited from class java.awt.KeyboardFocusManager |
|
Field Summary | |
private KeyboardFocusManager |
delegate
|
Fields inherited from class javax.swing.DefaultFocusManager |
gluePolicy |
Fields inherited from class javax.swing.FocusManager |
FOCUS_MANAGER_CLASS_PROPERTY |
Fields inherited from class java.awt.DefaultKeyboardFocusManager |
|
Fields inherited from class java.awt.KeyboardFocusManager |
BACKWARD_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS, FORWARD_TRAVERSAL_KEYS, UP_CYCLE_TRAVERSAL_KEYS |
Constructor Summary | |
(package private) |
DelegatingDefaultFocusManager(KeyboardFocusManager delegate)
|
Method Summary | |
void |
addKeyEventDispatcher(KeyEventDispatcher dispatcher)
Adds a KeyEventDispatcher to this KeyboardFocusManager's dispatcher chain. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. |
void |
addVetoableChangeListener(String propertyName,
java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list for a specific property. |
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list. |
void |
clearGlobalFocusOwner()
Clears the global focus owner at both the Java and native levels. |
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. |
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. |
Window |
getActiveWindow()
Returns the active Window, if the active Window is in the same context as the calling thread. |
Container |
getCurrentFocusCycleRoot()
Returns the current focus cycle root, if the current focus cycle root is in the same context as the calling thread. |
Set |
getDefaultFocusTraversalKeys(int id)
Returns a Set of default focus traversal keys for a given traversal operation. |
FocusTraversalPolicy |
getDefaultFocusTraversalPolicy()
Returns the default FocusTraversalPolicy. |
(package private) KeyboardFocusManager |
getDelegate()
|
Window |
getFocusedWindow()
Returns the focused Window, if the focused Window is in the same context as the calling thread. |
Component |
getFocusOwner()
Returns the focus owner, if the focus owner is in the same context as the calling thread. |
Component |
getPermanentFocusOwner()
Returns the permanent focus owner, if the permanent focus owner is in the same context as the calling thread. |
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. |
void |
removeKeyEventDispatcher(KeyEventDispatcher dispatcher)
Removes a KeyEventDispatcher which was previously added to this KeyboardFocusManager's dispatcher chain. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. |
void |
removeVetoableChangeListener(String propertyName,
java.beans.VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list for a specific property. |
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list. |
void |
setDefaultFocusTraversalKeys(int id,
Set keystrokes)
Sets the default focus traversal keys for a given traversal operation. |
void |
setDefaultFocusTraversalPolicy(FocusTraversalPolicy defaultPolicy)
Sets the default FocusTraversalPolicy. |
void |
setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot)
Sets the current focus cycle root. |
void |
upFocusCycle(Component aComponent)
Moves the focus up one focus traversal cycle. |
Methods inherited from class javax.swing.DefaultFocusManager |
compareTabOrder, getComponentAfter, getComponentBefore, getFirstComponent, getLastComponent |
Methods inherited from class javax.swing.FocusManager |
disableSwingFocusManager, getCurrentManager, isFocusManagerEnabled, setCurrentManager |
Methods inherited from class java.awt.DefaultKeyboardFocusManager |
dequeueKeyEvents, discardKeyEvents, enqueueKeyEvents, postProcessKeyEvent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private final KeyboardFocusManager delegate
Constructor Detail |
DelegatingDefaultFocusManager(KeyboardFocusManager delegate)
Method Detail |
KeyboardFocusManager getDelegate()
public void processKeyEvent(Component focusedComponent, KeyEvent e)
DefaultKeyboardFocusManager
processKeyEvent
in class DefaultKeyboardFocusManager
focusedComponent
- the Component that is 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 keypublic void focusNextComponent(Component aComponent)
DefaultKeyboardFocusManager
focusNextComponent
in class DefaultKeyboardFocusManager
aComponent
- the Component that is the basis for the focus
traversal operationFocusTraversalPolicy
,
Component.transferFocus()
public void focusPreviousComponent(Component aComponent)
DefaultKeyboardFocusManager
focusPreviousComponent
in class DefaultKeyboardFocusManager
aComponent
- the Component that is the basis for the focus
traversal operationFocusTraversalPolicy
,
Component.transferFocusBackward()
public Component getFocusOwner()
KeyboardFocusManager
getFocusOwner
in class KeyboardFocusManager
KeyboardFocusManager.getGlobalFocusOwner()
,
KeyboardFocusManager.setGlobalFocusOwner(java.awt.Component)
public void clearGlobalFocusOwner()
KeyboardFocusManager
requestFocus()
. This operation
does not change the focused or active Windows.
clearGlobalFocusOwner
in class KeyboardFocusManager
Component.requestFocus()
,
FocusEvent.FOCUS_LOST
public Component getPermanentFocusOwner()
KeyboardFocusManager
getPermanentFocusOwner
in class KeyboardFocusManager
KeyboardFocusManager.getGlobalPermanentFocusOwner()
,
KeyboardFocusManager.setGlobalPermanentFocusOwner(java.awt.Component)
public Window getFocusedWindow()
KeyboardFocusManager
getFocusedWindow
in class KeyboardFocusManager
KeyboardFocusManager.getGlobalFocusedWindow()
,
KeyboardFocusManager.setGlobalFocusedWindow(java.awt.Window)
public Window getActiveWindow()
KeyboardFocusManager
getActiveWindow
in class KeyboardFocusManager
KeyboardFocusManager.getGlobalActiveWindow()
,
KeyboardFocusManager.setGlobalActiveWindow(java.awt.Window)
public FocusTraversalPolicy getDefaultFocusTraversalPolicy()
KeyboardFocusManager
getDefaultFocusTraversalPolicy
in class KeyboardFocusManager
KeyboardFocusManager.setDefaultFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalPolicy(FocusTraversalPolicy defaultPolicy)
KeyboardFocusManager
setDefaultFocusTraversalPolicy
in class KeyboardFocusManager
defaultPolicy
- the new, default FocusTraversalPolicyKeyboardFocusManager.getDefaultFocusTraversalPolicy()
,
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalKeys(int id, Set keystrokes)
KeyboardFocusManager
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.
setDefaultFocusTraversalKeys
in class KeyboardFocusManager
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 operationKeyboardFocusManager.getDefaultFocusTraversalKeys(int)
,
Component.setFocusTraversalKeys(int, java.util.Set)
,
Component.getFocusTraversalKeys(int)
public Set getDefaultFocusTraversalKeys(int id)
KeyboardFocusManager
setDefaultFocusTraversalKeys
for a full description of each
operation.)
getDefaultFocusTraversalKeys
in class KeyboardFocusManager
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 returnedKeyboardFocusManager.setDefaultFocusTraversalKeys(int, java.util.Set)
,
Component.setFocusTraversalKeys(int, java.util.Set)
,
Component.getFocusTraversalKeys(int)
public Container getCurrentFocusCycleRoot()
KeyboardFocusManager
This method is intended to be used only by KeyboardFocusManagers and focus implementations. It is not for general client use.
getCurrentFocusCycleRoot
in class KeyboardFocusManager
KeyboardFocusManager.getGlobalCurrentFocusCycleRoot()
,
KeyboardFocusManager.setGlobalCurrentFocusCycleRoot(java.awt.Container)
public void setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot)
KeyboardFocusManager
This method is intended to be used only by KeyboardFocusManagers and focus implementations. It is not for general client use.
setGlobalCurrentFocusCycleRoot
in class KeyboardFocusManager
newFocusCycleRoot
- the new focus cycle rootKeyboardFocusManager.getCurrentFocusCycleRoot()
,
KeyboardFocusManager.getGlobalCurrentFocusCycleRoot()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
KeyboardFocusManager
addPropertyChangeListener
in class KeyboardFocusManager
listener
- the PropertyChangeListener to be addedKeyboardFocusManager.removePropertyChangeListener(java.beans.PropertyChangeListener)
,
KeyboardFocusManager.getPropertyChangeListeners()
,
KeyboardFocusManager.addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
KeyboardFocusManager
If listener is null, no exception is thrown and no action is performed.
removePropertyChangeListener
in class KeyboardFocusManager
listener
- the PropertyChangeListener to be removedKeyboardFocusManager.addPropertyChangeListener(java.beans.PropertyChangeListener)
,
KeyboardFocusManager.getPropertyChangeListeners()
,
KeyboardFocusManager.removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void addPropertyChangeListener(String propertyName, java.beans.PropertyChangeListener listener)
KeyboardFocusManager
addPropertyChangeListener
in class KeyboardFocusManager
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be addedKeyboardFocusManager.addPropertyChangeListener(java.beans.PropertyChangeListener)
,
KeyboardFocusManager.removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
KeyboardFocusManager.getPropertyChangeListeners(java.lang.String)
public void removePropertyChangeListener(String propertyName, java.beans.PropertyChangeListener listener)
KeyboardFocusManager
If listener is null, no exception is thrown and no action is performed.
removePropertyChangeListener
in class KeyboardFocusManager
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removedKeyboardFocusManager.addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
,
KeyboardFocusManager.getPropertyChangeListeners(java.lang.String)
,
KeyboardFocusManager.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
KeyboardFocusManager
addVetoableChangeListener
in class KeyboardFocusManager
listener
- the VetoableChangeListener to be addedKeyboardFocusManager.removeVetoableChangeListener(java.beans.VetoableChangeListener)
,
KeyboardFocusManager.getVetoableChangeListeners()
,
KeyboardFocusManager.addVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
KeyboardFocusManager
If listener is null, no exception is thrown and no action is performed.
removeVetoableChangeListener
in class KeyboardFocusManager
listener
- the VetoableChangeListener to be removedKeyboardFocusManager.addVetoableChangeListener(java.beans.VetoableChangeListener)
,
KeyboardFocusManager.getVetoableChangeListeners()
,
KeyboardFocusManager.removeVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public void addVetoableChangeListener(String propertyName, java.beans.VetoableChangeListener listener)
KeyboardFocusManager
addVetoableChangeListener
in class KeyboardFocusManager
propertyName
- one of the property names listed abovelistener
- the VetoableChangeListener to be addedKeyboardFocusManager.addVetoableChangeListener(java.beans.VetoableChangeListener)
,
KeyboardFocusManager.removeVetoableChangeListener(java.beans.VetoableChangeListener)
,
KeyboardFocusManager.getVetoableChangeListeners()
public void removeVetoableChangeListener(String propertyName, java.beans.VetoableChangeListener listener)
KeyboardFocusManager
If listener is null, no exception is thrown and no action is performed.
removeVetoableChangeListener
in class KeyboardFocusManager
propertyName
- a valid property namelistener
- the VetoableChangeListener to be removedKeyboardFocusManager.addVetoableChangeListener(java.beans.VetoableChangeListener)
,
KeyboardFocusManager.getVetoableChangeListeners()
,
KeyboardFocusManager.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public void addKeyEventDispatcher(KeyEventDispatcher dispatcher)
KeyboardFocusManager
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.
addKeyEventDispatcher
in class KeyboardFocusManager
dispatcher
- the KeyEventDispatcher to add to the dispatcher chainKeyboardFocusManager.removeKeyEventDispatcher(java.awt.KeyEventDispatcher)
public void removeKeyEventDispatcher(KeyEventDispatcher dispatcher)
KeyboardFocusManager
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.
removeKeyEventDispatcher
in class KeyboardFocusManager
dispatcher
- the KeyEventDispatcher to remove from the dispatcher
chainKeyboardFocusManager.addKeyEventDispatcher(java.awt.KeyEventDispatcher)
public boolean dispatchEvent(AWTEvent e)
DefaultKeyboardFocusManager
false
, then the AWT event
dispatcher will attempt to dispatch the event itself.
dispatchEvent
in class DefaultKeyboardFocusManager
e
- the AWTEvent to be dispatched
true
if this method dispatched the event;
false
otherwisepublic boolean dispatchKeyEvent(KeyEvent e)
DefaultKeyboardFocusManager
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.
dispatchKeyEvent
in interface KeyEventDispatcher
dispatchKeyEvent
in class DefaultKeyboardFocusManager
e
- the KeyEvent to be dispatched
true
Component.dispatchEvent(java.awt.AWTEvent)
public void upFocusCycle(Component aComponent)
DefaultKeyboardFocusManager
upFocusCycle
in class DefaultKeyboardFocusManager
aComponent
- the Component that is the basis for the focus
traversal operationComponent.transferFocusUpCycle()
public void downFocusCycle(Container aContainer)
DefaultKeyboardFocusManager
downFocusCycle
in class DefaultKeyboardFocusManager
aContainer
- the Container that is the basis for the focus
traversal operationContainer.transferFocusDownCycle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |