java.awt
Class DefaultKeyboardFocusManager

java.lang.Object
  extended by java.awt.KeyboardFocusManager
      extended by java.awt.DefaultKeyboardFocusManager
All Implemented Interfaces:
KeyEventDispatcher, KeyEventPostProcessor
Direct Known Subclasses:
FocusManager

public class DefaultKeyboardFocusManager
extends KeyboardFocusManager


Field Summary
 
Fields inherited from class java.awt.KeyboardFocusManager
BACKWARD_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS, FORWARD_TRAVERSAL_KEYS, UP_CYCLE_TRAVERSAL_KEYS
 
Constructor Summary
DefaultKeyboardFocusManager()
           
 
Method Summary
protected  void dequeueKeyEvents(long after, Component untilFocused)
          Removes the key event block specified by the supplied timestamp and component.
protected  void discardKeyEvents(Component comp)
          Discards all key event blocks relating to focus requirements for the supplied component, regardless of timestamp.
 boolean dispatchEvent(AWTEvent e)
          The AWT event dispatcher uses this method to request that the manager handle a particular event.
 boolean dispatchKeyEvent(KeyEvent e)
          Attempts to dispatch key events for which no key event dispatcher has so far succeeded.
 void downFocusCycle(Container cont)
          Moves the current focus downwards by one focus cycle.
protected  void enqueueKeyEvents(long after, Component untilFocused)
          Delays all key events following the specified timestamp until the supplied component has focus.
 void focusNextComponent(Component comp)
          Moves the current focus to the next component following comp, based on the current focus traversal policy.
 void focusPreviousComponent(Component comp)
          Moves the current focus to the previous component, prior to comp, based on the current focus traversal policy.
 boolean postProcessKeyEvent(KeyEvent e)
          Handles the post processing of key events.
 void processKeyEvent(Component comp, KeyEvent e)
          Handles focus traversal operations for key events which represent focus traversal keys in relation to the supplied component.
 void upFocusCycle(Component comp)
          Moves the current focus upwards by one focus cycle.
 
Methods inherited from class java.awt.KeyboardFocusManager
addKeyEventDispatcher, addKeyEventPostProcessor, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clearGlobalFocusOwner, downFocusCycle, firePropertyChange, fireVetoableChange, focusNextComponent, focusPreviousComponent, getActiveWindow, getCurrentFocusCycleRoot, getCurrentKeyboardFocusManager, getDefaultFocusTraversalKeys, getDefaultFocusTraversalPolicy, getFocusedWindow, getFocusOwner, getGlobalActiveWindow, getGlobalCurrentFocusCycleRoot, getGlobalFocusedWindow, getGlobalFocusOwner, getGlobalPermanentFocusOwner, getKeyEventDispatchers, getKeyEventPostProcessors, getPermanentFocusOwner, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, redispatchEvent, removeKeyEventDispatcher, removeKeyEventPostProcessor, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setCurrentKeyboardFocusManager, setDefaultFocusTraversalKeys, setDefaultFocusTraversalPolicy, setGlobalActiveWindow, setGlobalCurrentFocusCycleRoot, setGlobalFocusedWindow, setGlobalFocusOwner, setGlobalPermanentFocusOwner, upFocusCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultKeyboardFocusManager

public DefaultKeyboardFocusManager()
Method Detail

dispatchEvent

public boolean dispatchEvent(AWTEvent e)
Description copied from class: KeyboardFocusManager
The AWT event dispatcher uses this method to request that the manager handle a particular event. If the manager fails or refuses to dispatch the supplied event (this method returns false), the AWT event dispatcher will try to dispatch the event itself.

The manager is expected to handle all FocusEvents and KeyEvents, and WindowEvents relating to the focus. Dispatch is done with regard to the the focus owner and the currently focused and active windows. In handling the event, the source of the event may be overridden.

The actual dispatching is performed by calling redispatchEvent(). This avoids the infinite recursion of dispatch requests which may occur if this method is called on the target component.

Specified by:
dispatchEvent in class KeyboardFocusManager
Parameters:
e - the event to dispatch.
Returns:
true if the event was dispatched.
See Also:
KeyboardFocusManager.redispatchEvent(java.awt.Component, java.awt.AWTEvent), KeyEvent, FocusEvent, WindowEvent

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent e)
Description copied from class: KeyboardFocusManager
Attempts to dispatch key events for which no key event dispatcher has so far succeeded. This method is usually called by dispatchEvent() following the sending of the key event to any registered key event dispatchers. If the key event reaches this stage, none of the dispatchers returned true. This is, of course, always the case if there are no registered dispatchers.

If this method also fails to handle the key event, then false is returned to the caller. In the case of dispatchEvent(), the calling method may try to handle the event itself or simply forward on the false result to its caller. When the event is dispatched by this method, a true result is propogated through the calling methods.

Specified by:
dispatchKeyEvent in interface KeyEventDispatcher
Specified by:
dispatchKeyEvent in class KeyboardFocusManager
Parameters:
e - the key event to dispatch.
Returns:
true if the event was dispatched successfully.
See Also:
KeyboardFocusManager.redispatchEvent(Component, AWTEvent)

postProcessKeyEvent

public boolean postProcessKeyEvent(KeyEvent e)
Description copied from class: KeyboardFocusManager
Handles the post processing of key events. By default, this method will map unhandled key events to appropriate MenuShortcuts. The event is consumed in the process and the shortcut is activated. This method is usually called by dispatchKeyEvent.

Specified by:
postProcessKeyEvent in interface KeyEventPostProcessor
Specified by:
postProcessKeyEvent in class KeyboardFocusManager
Parameters:
e - the key event to post process.
Returns:
true by default, as the event was handled.
See Also:
KeyboardFocusManager.redispatchEvent(Component, AWTEvent)

processKeyEvent

public void processKeyEvent(Component comp,
                            KeyEvent e)
Description copied from class: KeyboardFocusManager
Handles focus traversal operations for key events which represent focus traversal keys in relation to the supplied component. The supplied component is assumed to have the focus, whether it does so or not, and the operation is carried out as appropriate, with this in mind.

Specified by:
processKeyEvent in class KeyboardFocusManager
Parameters:
comp - the component on which to perform focus traversal, on the assumption that this component has the focus.
e - the possible focus traversal key event.

enqueueKeyEvents

protected void enqueueKeyEvents(long after,
                                Component untilFocused)
Description copied from class: KeyboardFocusManager
Delays all key events following the specified timestamp until the supplied component has focus. The AWT calls this method when it is determined that a focus change may occur within the native windowing system. Any key events which occur following the time specified by after are delayed until a FOCUS_GAINED event is received for the untilFocused component. The manager is responsible for ensuring this takes place.

Specified by:
enqueueKeyEvents in class KeyboardFocusManager
Parameters:
after - the timestamp beyond which all key events are delayed until the supplied component gains focus.
untilFocused - the component to wait on gaining focus.

dequeueKeyEvents

protected void dequeueKeyEvents(long after,
                                Component untilFocused)
Description copied from class: KeyboardFocusManager
Removes the key event block specified by the supplied timestamp and component. All delayed key events are released for normal dispatching following its removal and subsequent key events that would have been blocked are now immediately dispatched. If the specified timestamp is below 0, then the request with the oldest timestamp is removed.

Specified by:
dequeueKeyEvents in class KeyboardFocusManager
Parameters:
after - the timestamp of the key event block to be removed, or a value smaller than 0 if the oldest is to be removed.
untilFocused - the component of the key event block to be removed.

discardKeyEvents

protected void discardKeyEvents(Component comp)
Description copied from class: KeyboardFocusManager
Discards all key event blocks relating to focus requirements for the supplied component, regardless of timestamp.

Specified by:
discardKeyEvents in class KeyboardFocusManager
Parameters:
comp - the component of the key event block(s) to be removed.

focusPreviousComponent

public void focusPreviousComponent(Component comp)
Description copied from class: KeyboardFocusManager
Moves the current focus to the previous component, prior to comp, based on the current focus traversal policy. By default, only visible, displayable, accepted components can receive focus. Canvases, Panels, Labels, ScrollPanes, Scrollbars, Windows and lightweight components are judged to be unacceptable by default. See the DefaultFocusTraversalPolicy for more details.

Specified by:
focusPreviousComponent in class KeyboardFocusManager
Parameters:
comp - the component following the one which will become the focus, following execution of this method.
See Also:
DefaultFocusTraversalPolicy

focusNextComponent

public void focusNextComponent(Component comp)
Description copied from class: KeyboardFocusManager
Moves the current focus to the next component following comp, based on the current focus traversal policy. By default, only visible, displayable, accepted components can receive focus. Canvases, Panels, Labels, ScrollPanes, Scrollbars, Windows and lightweight components are judged to be unacceptable by default. See the DefaultFocusTraversalPolicy for more details.

Specified by:
focusNextComponent in class KeyboardFocusManager
Parameters:
comp - the component prior to the one which will become the focus, following execution of this method.
See Also:
DefaultFocusTraversalPolicy

upFocusCycle

public void upFocusCycle(Component comp)
Description copied from class: KeyboardFocusManager
Moves the current focus upwards by one focus cycle. Both the current focus owner and current focus cycle root become the focus cycle root of the supplied component. However, in the case of a Window, the default focus component becomes the focus owner and the focus cycle root is not changed.

Specified by:
upFocusCycle in class KeyboardFocusManager
Parameters:
comp - the component used as part of the focus traversal.

downFocusCycle

public void downFocusCycle(Container cont)
Description copied from class: KeyboardFocusManager
Moves the current focus downwards by one focus cycle. If the supplied container is a focus cycle root, then this becomes the current focus cycle root and the focus goes to the default component of the specified container. Nothing happens for non-focus cycle root containers.

Specified by:
downFocusCycle in class KeyboardFocusManager
Parameters:
cont - the container used as part of the focus traversal.