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

Window.java should call peer class to check for focus traversal

XMLWordPrintable

    • 1.2beta4
    • generic
    • generic

      The gestures for focus traversal are platform specific (TAB and Shift-TAB in
      Windows and Motif environments but different in other windowing systems).

      java.awt.Window hardcodes TAB and Shift-TAB to implement focus traversal which
      means that other Windowing environments need to change the shared code for
      their native scheme. This is not desirable as the shared code should be portable.

      The problem in Window.java is the postProcessKeyEvent method which calls
      handleTabEvent prior to consuming the event. Instead of calling handleTabEvent
      it should instead call a peer class which decides if a focus traversal has
      been requested -- eg: the peer code for Win32 should check for TAB and
      shift-TAB.

      This issue has been uncovered as part of the JAE port to the Psion EPOC32
      environment (palm top computer). The native windowing system in this
      environment is called EIKON and the use of the TAB key conflicits with the
      native environment.

      The following extract from src/share/java/java/awt/Window.java demonstrates
      the problem :-

          /* Handle TAB and Shift-TAB events. */
          private boolean handleTabEvent(KeyEvent e) {
              if (e.getKeyCode() != '\t' || (e.getSource() instanceof TextArea)) {
                  return false;
              }
              if ((e.getModifiers() & ~InputEvent.SHIFT_MASK) > 0) {
                  return false;
              }
              int id = e.getID();
              if (id == KeyEvent.KEY_RELEASED || id == KeyEvent.KEY_TYPED) {
                  return true;
              }
              if (e.isShiftDown()) {
                  return focusMgr.focusPrevious();
              } else {
                  return focusMgr.focusNext();
              }
          }

          void postProcessKeyEvent(KeyEvent e) {
              if (handleTabEvent(e)) {
                  e.consume();
                  return;
              }
          }


            duke J. Duke
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: