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

Swing/AWT applications lose keyboard focus permanently

XMLWordPrintable

      FULL PRODUCT VERSION :
      tams113> java -version
      java version " 1.7.0_13 "
      OpenJDK Runtime Environment (IcedTea7 2.3.6) (7u13-2.3.6-0ubuntu0.12.04.1)
      OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

      Doesn't matter. The bug has been on every single 1.7 version ever.


      ADDITIONAL OS VERSION INFORMATION :
      Ubuntu 12.04 LTS, also observed on Ubuntu 11.04 and OpenSusue

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Xfce with " focus-follows-mouse " enabled. Also happens with several
      other window managers.

      A DESCRIPTION OF THE PROBLEM :
      Probably the same as:
      6798064 : Keyboard focus is lost in Swing application after switching to window

      but the stupid bug-database doesn't let me reopen the bug. This has been
      the single show-stopper that keeps me on JDK 1.6 for years now.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use any Swing app you want. Keyboard focus initially works. Switch
      focus to another window, then back to the Swing app. NO keyboard
      focus anymore. Applications reacts to mouse as usual, but no way
      to have keystrokes anymore.

      If I believe 6798064, this may be related to " focus-follows-mouse "
      setting in the window-manager. But anyway, the Window manager
      highlights the Java window, indicating that it HAS the keyboard focus.

      You KNOW the bug. Happens on ANY AWT/Swing application with
      XFCE/ion3/ctwm/ whatever window manager I ever tried. I can
      provide a recent build of my Java-based image-viewer/editor (with
      source-code) if you really need it.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Calling requestFocusInWindow() should give the keyboard focus
      back to my application. But no, focus is lost forever.

      It works on Linux with JDK 1.6 and lower. It is crippled in JDK 1.7
      for years. It may work on Windows, but then, why use Java?
      ACTUAL -
      Application loses focus.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      It's been introduced by the following focus changes (part of 6522725):

      src/solaris/classes/sun/awt/X11/XDecoratedPeer.java

      public boolean requestWindowFocus(...)

      + if (target == realNativeFocusedWindow) {
      + focusLog.fine( " The window is already natively focused. " );
      + return true;
      + }

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Any Java code that uses keyboard input.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Windows. Use JDK 1.6. Forget the 10+ years of your life that you
      believed in a broken platform.

            dmarkov Dmitry Markov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: