Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6244370

Spec for Component.processFocusEvent/processKeyEvent doesn't match the implementation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs
    • Cause Known
    • sparc
    • solaris_9

      The current specs for Component.processFocusEvent/processKeyEvent
      state:

          If focus events are enabled for a Component, the current
          KeyboardFocusManager determines whether or not a focus
          event should be dispatched to registered FocusListener
          objects. If the events are to be dispatched, the
          KeyboardFocusManager calls the Component's dispatchEvent
          method, which results in a call to the Component's
          processFocusEvent method.

          If focus events are enabled for a Component, calling the
          Component's dispatchEvent method with a FocusEvent as the
          argument will result in a call to the Component's
          processFocusEvent method regardless of the current
          KeyboardFocusManager.

          ....

          If key events are enabled for a Component, the current
          KeyboardFocusManager determines whether or not a key event
          should be dispatched to registered KeyListener objects.
          <...>

          As of J2SE 1.4, KeyEvents are redirected to the focus owner.
          Please see the Focus Specification for further information.

          Calling a Component's dispatchEvent method with a KeyEvent
          as the argument will result in a call to the Component's
          processKeyEvent method regardless of the current
          KeyboardFocusManager as long as the component is showing,
          focused, and enabled, and key events are enabled on it.

      There's a few issues with this doc:

      1) Both statements with "..regardless of the current KeyboardFocusManager"
      do not match Sun's implementation - the current KeyboardFocusManager is
      consulted even if the event doesn't come from the EventQueue but is synthesized
      by the application and dispatched to the component directly. I attached code
      examples for both cases: just uncomment the redispatchEvent() calls and the
      events will be delivered.

      2) The spec for processFocusEvent seems to imply that FocusEvents
      are processed *as if* the current KFM is consulted before calling
      Component.dispatchEvent(): an implementation may choose to put KFM
      calls into Component.dispatchEvent() (it's final anyway, and this
      is how Sun's impl does it), but this should be invisible to
      applications. The spec for processKeyEvent happens to be more ambigious
      and does not specify at what point applications will perceive interactions
      with the current KFM.

      3) The last statement seems to have contradiction in itself ("regardless of
      the current KeyboardFocusManager as long as the component is <..> focused")
      since the focused component is actually determined by the current
      KeyboardFocusManager.


      ###@###.### 2005-03-22 18:45:50 GMT

            ant Anton Tarasov (Inactive)
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: