public abstract class KeyboardFocusManager extends Objectimplements KeyEventDispatcher , KeyEventPostProcessor
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.
Please see How to Use the Focus Subsystem, a section in The Java Tutorial, and the Focus Specification for more information.
Window,
Frame,
Dialog,
FocusEvent,
WindowEvent,
KeyEvent
| Modifier and Type | Field and Description |
|---|---|
static int |
BACKWARD_TRAVERSAL_KEYS
The identifier for the Backward focus traversal keys.
|
static int |
DOWN_CYCLE_TRAVERSAL_KEYS
The identifier for the Down Cycle focus traversal keys.
|
static int |
FORWARD_TRAVERSAL_KEYS
The identifier for the Forward focus traversal keys.
|
static int |
UP_CYCLE_TRAVERSAL_KEYS
The identifier for the Up Cycle focus traversal keys.
|
| Constructor and Description |
|---|
KeyboardFocusManager()
Initializes a KeyboardFocusManager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addKeyEventDispatcher(KeyEventDispatcher
Adds a KeyEventDispatcher to this KeyboardFocusManager's dispatcher chain.
|
void |
addKeyEventPostProcessor(KeyEventPostProcessor
Adds a KeyEventPostProcessor to this KeyboardFocusManager's post- processor chain.
|
void |
addPropertyChangeListener(PropertyChangeListener
Adds a PropertyChangeListener to the listener list.
|
void |
addPropertyChangeListener(String
Adds a PropertyChangeListener to the listener list for a specific property.
|
void |
addVetoableChangeListener(String
Adds a VetoableChangeListener to the listener list for a specific property.
|
void |
addVetoableChangeListener(VetoableChangeListener
Adds a VetoableChangeListener to the listener list.
|
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.
|
void |
clearGlobalFocusOwner()
Clears the global focus owner at both the Java and native levels.
|
protected abstract void |
dequeueKeyEvents(long after, Component
Called by the AWT to notify the KeyboardFocusManager that it should cancel delayed dispatching of KeyEvents.
|
protected abstract void |
discardKeyEvents(Component
Called by the AWT to notify the KeyboardFocusManager that it should cancel delayed dispatching of KeyEvents.
|
abstract boolean |
dispatchEvent(AWTEvent
This method is called by the AWT event dispatcher requesting that the current KeyboardFocusManager dispatch the specified event on its behalf.
|
abstract boolean |
dispatchKeyEvent(KeyEvent
Typically this method will be 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 from the current focus owner, if and only if the current focus owner is a Container that is a focus cycle root.
|
abstract void |
downFocusCycle(Container
Moves the focus down one focus traversal cycle.
|
protected abstract void |
enqueueKeyEvents(long after, Component
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
Fires a PropertyChangeEvent in response to a change in a bound property.
|
protected void |
fireVetoableChange(String
Fires a PropertyChangeEvent in response to a change in a vetoable property.
|
void |
focusNextComponent()
Focuses the Component after the current focus owner.
|
abstract void |
focusNextComponent(Component
Focuses the Component after aComponent, typically based on a FocusTraversalPolicy.
|
void |
focusPreviousComponent()
Focuses the Component before the current focus owner.
|
abstract void |
focusPreviousComponent(Component
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.
|
static KeyboardFocusManager |
getCurrentKeyboardFocusManager()
Returns the current KeyboardFocusManager instance for the calling thread's context.
|
Set |
getDefaultFocusTraversalKeys(int id)
Returns a Set of default focus traversal keys for a given traversal operation.
|
FocusTraversalPolicy |
getDefaultFocusTraversalPolicy()
Returns the default FocusTraversalPolicy.
|
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.
|
protected Window |
getGlobalActiveWindow()
Returns the active Window, even if the calling thread is in a different context than the active Window.
|
protected Container |
getGlobalCurrentFocusCycleRoot()
Returns the current focus cycle root, even if the calling thread is in a different context than the current focus cycle root.
|
protected Window |
getGlobalFocusedWindow()
Returns the focused Window, even if the calling thread is in a different context than the focused Window.
|
protected Component |
getGlobalFocusOwner()
Returns the focus owner, even if the calling thread is in a different context than the focus owner.
|
protected Component |
getGlobalPermanentFocusOwner()
Returns the permanent focus owner, even if the calling thread is in a different context than the permanent focus owner.
|
protected List |
getKeyEventDispatchers()
Returns this KeyboardFocusManager's KeyEventDispatcher chain as a List.
|
protected List |
getKeyEventPostProcessors()
Returns this KeyboardFocusManager's KeyEventPostProcessor chain as a List.
|
Component |
getPermanentFocusOwner()
Returns the permanent focus owner, if the permanent focus owner is in the same context as the calling thread.
|
PropertyChangeListener |
getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this keyboard focus manager.
|
PropertyChangeListener |
getPropertyChangeListeners(String
Returns an array of all the
PropertyChangeListeners associated with the named property.
|
VetoableChangeListener |
getVetoableChangeListeners()
Returns an array of all the vetoable change listeners registered on this keyboard focus manager.
|
VetoableChangeListener |
getVetoableChangeListeners(String
Returns an array of all the
VetoableChangeListeners associated with the named property.
|
abstract boolean |
postProcessKeyEvent(KeyEvent
This method will be called by
dispatchKeyEvent.
|
abstract void |
processKeyEvent(Component
This method initiates a focus traversal operation if and only if the KeyEvent represents a focus traversal key for the specified focusedComponent.
|
void |
redispatchEvent(Component
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.
|
void |
removeKeyEventDispatcher(KeyEventDispatcher
Removes a KeyEventDispatcher which was previously added to this KeyboardFocusManager's dispatcher chain.
|
void |
removeKeyEventPostProcessor(KeyEventPostProcessor
Removes a previously added KeyEventPostProcessor from this KeyboardFocusManager's post-processor chain.
|
void |
removePropertyChangeListener(PropertyChangeListener
Removes a PropertyChangeListener from the listener list.
|
void |
removePropertyChangeListener(String
Removes a PropertyChangeListener from the listener list for a specific property.
|
void |
removeVetoableChangeListener(String
Removes a VetoableChangeListener from the listener list for a specific property.
|
void |
removeVetoableChangeListener(VetoableChangeListener
Removes a VetoableChangeListener from the listener list.
|
static void |
setCurrentKeyboardFocusManager(KeyboardFocusManager
Sets the current KeyboardFocusManager instance for the calling thread's context.
|
void |
setDefaultFocusTraversalKeys(int id, Set
Sets the default focus traversal keys for a given traversal operation.
|
void |
setDefaultFocusTraversalPolicy(FocusTraversalPolicy
Sets the default FocusTraversalPolicy.
|
protected void |
setGlobalActiveWindow(Window
Sets the active Window.
|
void |
setGlobalCurrentFocusCycleRoot(Container
Sets the current focus cycle root.
|
protected void |
setGlobalFocusedWindow(Window
Sets the focused Window.
|
protected void |
setGlobalFocusOwner(Component
Sets the focus owner.
|
protected void |
setGlobalPermanentFocusOwner(Component
Sets the permanent focus owner.
|
void |
upFocusCycle()
Moves the focus up one focus traversal cycle from the current focus owner.
|
abstract void |
upFocusCycle(Component
Moves the focus up one focus traversal cycle.
|
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
public KeyboardFocusManager()
public static KeyboardFocusManagergetCurrentKeyboardFocusManager()
setCurrentKeyboardFocusManager(java.awt.KeyboardFocusManager)
public static void setCurrentKeyboardFocusManager(KeyboardFocusManagernewManager) 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 KeyboardFocusManager
getCurrentKeyboardFocusManager(),
DefaultKeyboardFocusManager
public ComponentgetFocusOwner()
getGlobalFocusOwner(),
setGlobalFocusOwner(java.awt.Component)
protected ComponentgetGlobalFocusOwner() 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 context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getFocusOwner(),
setGlobalFocusOwner(java.awt.Component)
protected void setGlobalFocusOwner(ComponentfocusOwner) throws SecurityException
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 owner
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getFocusOwner(),
getGlobalFocusOwner(),
Component.requestFocus() ,
Component.requestFocusInWindow() ,
Component.isFocusable()
public void clearFocusOwner()
The focus owner component will receive a permanent FOCUS_LOST event. After this operation completes, the native windowing system will discard all user-generated KeyEvents until the user selects a new Component to receive focus, or a Component is given focus explicitly via a call to requestFocus(). This operation does not change the focused or active Windows.
Component.requestFocus() ,
FocusEvent.FOCUS_LOST
public void clearGlobalFocusOwner()
throws SecurityException
requestFocus(). This operation does not change the focused or active Windows.
If a SecurityManager is installed, the calling thread must be granted the "replaceKeyboardFocusManager" AWTPermission. If this permission is not granted, this method will throw a SecurityException, and the current focus owner will not be cleared.
This method is intended to be used only by KeyboardFocusManager set as current KeyboardFocusManager for the calling thread's context. It is not for general client use.
SecurityException - if the calling thread does not have "replaceKeyboardFocusManager" permission
clearFocusOwner(),
Component.requestFocus() ,
FocusEvent.FOCUS_LOST
public ComponentgetPermanentFocusOwner()
getGlobalPermanentFocusOwner(),
setGlobalPermanentFocusOwner(java.awt.Component)
protected ComponentgetGlobalPermanentFocusOwner() throws SecurityException
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getPermanentFocusOwner(),
setGlobalPermanentFocusOwner(java.awt.Component)
protected void setGlobalPermanentFocusOwner(ComponentpermanentFocusOwner) throws SecurityException
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 owner
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getPermanentFocusOwner(),
getGlobalPermanentFocusOwner(),
Component.requestFocus() ,
Component.requestFocusInWindow() ,
Component.isFocusable()
public WindowgetFocusedWindow()
getGlobalFocusedWindow(),
setGlobalFocusedWindow(java.awt.Window)
protected WindowgetGlobalFocusedWindow() throws SecurityException
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getFocusedWindow(),
setGlobalFocusedWindow(java.awt.Window)
protected void setGlobalFocusedWindow(WindowfocusedWindow) throws SecurityException
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 Window
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getFocusedWindow(),
getGlobalFocusedWindow(),
Component.requestFocus() ,
Component.requestFocusInWindow() ,
Window.isFocusableWindow()
public WindowgetActiveWindow()
getGlobalActiveWindow(),
setGlobalActiveWindow(java.awt.Window)
protected WindowgetGlobalActiveWindow() throws SecurityException
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getActiveWindow(),
setGlobalActiveWindow(java.awt.Window)
protected void setGlobalActiveWindow(WindowactiveWindow) throws SecurityException
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 Window
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getActiveWindow(),
getGlobalActiveWindow(),
Component.requestFocus() ,
Component.requestFocusInWindow()
public FocusTraversalPolicygetDefaultFocusTraversalPolicy()
setDefaultFocusTraversalPolicy(java.awt.FocusTraversalPolicy),
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy) ,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalPolicy(FocusTraversalPolicydefaultPolicy)
defaultPolicy - the new, default FocusTraversalPolicy
IllegalArgumentException - if defaultPolicy is null
getDefaultFocusTraversalPolicy(),
Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy) ,
Container.getFocusTraversalPolicy()
public void setDefaultFocusTraversalKeys(int id,
Set<? extends AWTKeyStroke> keystrokes)
Set will be in effect on all
Windows 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 KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal operation will occur. Regardless of which KeyEvent is specified, however, all KeyEvents 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.
This method may throw a ClassCastException if any Object in keystrokes is not an AWTKeyStroke.
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
AWTKeyStrokes 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 keystroke represents a
KEY_TYPED event, or if any keystroke already maps to another default focus traversal operation
getDefaultFocusTraversalKeys(int),
Component.setFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>) ,
Component.getFocusTraversalKeys(int)
public Set<AWTKeyStroke > 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
AWTKeyStrokes 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_KEYS
setDefaultFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>),
Component.setFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>) ,
Component.getFocusTraversalKeys(int)
public ContainergetCurrentFocusCycleRoot()
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 ContainergetGlobalCurrentFocusCycleRoot() throws SecurityException
SecurityException - if this KeyboardFocusManager is not the current KeyboardFocusManager for the calling thread's context and if the calling thread does not have "replaceKeyboardFocusManager" permission
getCurrentFocusCycleRoot(),
setGlobalCurrentFocusCycleRoot(java.awt.Container)
public void setGlobalCurrentFocusCycleRoot(ContainernewFocusCycleRoot) throws SecurityException
If a SecurityManager is installed, the calling thread must be granted the "replaceKeyboardFocusManager" AWTPermission. If this permission is not granted, this method will throw a SecurityException, and the current focus cycle root will not be changed.
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 root
SecurityException - if the calling thread does not have "replaceKeyboardFocusManager" permission
getCurrentFocusCycleRoot(),
getGlobalCurrentFocusCycleRoot()
public void addPropertyChangeListener(PropertyChangeListenerlistener)
listener - the PropertyChangeListener to be added
removePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListenerlistener)
If listener is null, no exception is thrown and no action is performed.
listener - the PropertyChangeListener to be removed
addPropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListeners or an empty array if no property change listeners are currently registered
addPropertyChangeListener(java.beans.PropertyChangeListener),
removePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(java.lang.String)
public void addPropertyChangeListener(StringpropertyName, PropertyChangeListener listener)
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added
addPropertyChangeListener(java.beans.PropertyChangeListener),
removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener),
getPropertyChangeListeners(java.lang.String)
public void removePropertyChangeListener(StringpropertyName, PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener),
getPropertyChangeListeners(java.lang.String),
removePropertyChangeListener(java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
PropertyChangeListeners associated with the named property.
PropertyChangeListeners 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(StringpropertyName, Object oldValue, Object newValue)
propertyName - the name of the property that has changed
oldValue - the property's previous value
newValue - the property's new value
public void addVetoableChangeListener(VetoableChangeListenerlistener)
listener - the VetoableChangeListener to be added
removeVetoableChangeListener(java.beans.VetoableChangeListener),
getVetoableChangeListeners(),
addVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public void removeVetoableChangeListener(VetoableChangeListenerlistener)
If listener is null, no exception is thrown and no action is performed.
listener - the VetoableChangeListener to be removed
addVetoableChangeListener(java.beans.VetoableChangeListener),
getVetoableChangeListeners(),
removeVetoableChangeListener(java.lang.String,java.beans.VetoableChangeListener)
public VetoableChangeListener[] getVetoableChangeListeners()
VetoableChangeListeners or an empty array if no vetoable change listeners are currently registered
addVetoableChangeListener(java.beans.VetoableChangeListener),
removeVetoableChangeListener(java.beans.VetoableChangeListener),
getVetoableChangeListeners(java.lang.String)
public void addVetoableChangeListener(StringpropertyName, VetoableChangeListener listener)
propertyName - one of the property names listed above
listener - the VetoableChangeListener to be added
addVetoableChangeListener(java.beans.VetoableChangeListener),
removeVetoableChangeListener(java.beans.VetoableChangeListener),
getVetoableChangeListeners()
public void removeVetoableChangeListener(StringpropertyName, VetoableChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
propertyName - a valid property name
listener - the VetoableChangeListener to be removed
addVetoableChangeListener(java.beans.VetoableChangeListener),
getVetoableChangeListeners(),
removeVetoableChangeListener(java.beans.VetoableChangeListener)
public VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
VetoableChangeListeners associated with the named property.
VetoableChangeListeners 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(StringpropertyName, Object oldValue, Object newValue) throws PropertyVetoException
propertyName - the name of the property that has changed
oldValue - the property's previous value
newValue - the property's new value
PropertyVetoException - if a
VetoableChangeListener threw
PropertyVetoException
public void addKeyEventDispatcher(KeyEventDispatcherdispatcher)
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.
In a multithreaded application, KeyEventDispatcher behaves the same as other AWT listeners. See AWT Threading Issues for more details.
dispatcher - the KeyEventDispatcher to add to the dispatcher chain
removeKeyEventDispatcher(java.awt.KeyEventDispatcher)
public void removeKeyEventDispatcher(KeyEventDispatcherdispatcher)
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.
In a multithreaded application, KeyEventDispatcher behaves the same as other AWT listeners. See AWT Threading Issues for more details.
dispatcher - the KeyEventDispatcher to remove from the dispatcher chain
addKeyEventDispatcher(java.awt.KeyEventDispatcher)
protected List<KeyEventDispatcher > 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(KeyEventPostProcessorprocessor)
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.
In a multithreaded application, KeyEventPostProcessor behaves the same as other AWT listeners. See AWT Threading Issues for more details.
processor - the KeyEventPostProcessor to add to the post-processor chain
removeKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
public void removeKeyEventPostProcessor(KeyEventPostProcessorprocessor)
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.
In a multithreaded application, KeyEventPostProcessor behaves the same as other AWT listeners. See AWT Threading Issues for more details.
processor - the KeyEventPostProcessor to remove from the post- processor chain
addKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
protected List<KeyEventPostProcessor > 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)
public abstract boolean dispatchEvent(AWTEvente)
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 otherwise
redispatchEvent(java.awt.Component, java.awt.AWTEvent),
dispatchKeyEvent(java.awt.event.KeyEvent)
public final void redispatchEvent(Componenttarget, 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 dispatched
e - the event to dispatch
dispatchEvent(java.awt.AWTEvent),
KeyEventDispatcher
public abstract boolean dispatchKeyEvent(KeyEvente)
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 otherwise
dispatchEvent(java.awt.AWTEvent)
public abstract boolean postProcessKeyEvent(KeyEvente)
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(ComponentfocusedComponent, 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 Component
e - the event that may represent a focus traversal key
protected 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 handled
untilFocused - Component which should receive a FOCUS_GAINED event before any pending KeyEvents
dequeueKeyEvents(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 < 0
untilFocused - the Component specified in the call to
enqueueKeyEvents
enqueueKeyEvents(long, java.awt.Component),
discardKeyEvents(java.awt.Component)
protected abstract void discardKeyEvents(Componentcomp)
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(ComponentaComponent)
aComponent - the Component that is the basis for the focus traversal operation
FocusTraversalPolicy
public abstract void focusPreviousComponent(ComponentaComponent)
aComponent - the Component that is the basis for the focus traversal operation
FocusTraversalPolicy
public abstract void upFocusCycle(ComponentaComponent)
aComponent - the Component that is the basis for the focus traversal operation
public abstract void downFocusCycle(ContaineraContainer)
aContainer - the Container that is the basis for the focus traversal operation
public final void focusNextComponent()
public final void focusPreviousComponent()
public final void upFocusCycle()
public final void downFocusCycle()