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

No keyboard focus in a focusable JWindow

    XMLWordPrintable

Details

    • b01
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Keyboard focus is not transfered to JWindows with JFrame owners altough the JWindow is focusable.

      This is working properly under 1.4.2_12 , 1.5.0_6, 1.5.0_7. broken only in 1.5.0_8
      Maybe a side effect of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399303 ?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached program. Partially cover the JWindow with some other process's window and make sure this other window has keyboard focus. Now, use the mouse to click and select the text in the JWindow's text field.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      when the text field is clicked , the other window should be minimized, text field should gain keyboard focus
      ACTUAL -
      Text field does not gain keyboard focus . Other external window is not minimized

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      public class FocusTest {
        public static final void main(String[] args){
              JFrame mainFrame = new JFrame("Main frame");
              mainFrame.getContentPane().add(new JLabel("Main frame label"));
              mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              mainFrame.pack();
              JWindow sonWindow = new JWindow(mainFrame);
              sonWindow.getContentPane().add(new JLabel("Child Window label"));
              sonWindow.getContentPane().add(new JTextField("Child Window Field"));
              sonWindow.pack();
              sonWindow.show();
              mainFrame.show();
              System.out.println("Son window is focusable: "+sonWindow.isFocusable());
              System.out.println("Son window focusable state: "+sonWindow.getFocusableWindowState());

              //sonWindow.setFocusableWindowState(true); //uncommenting this line workaround the bug
        }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Calling sonWindow.setFocusableWindowState(true); after the window is shown fixes it. Note that the jwindow is focusable at this time!

      This workaround is not good for our application since we don't create the JWindows they are created by a third party framework.

      Release Regression From : 5.0u7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

      Attachments

        Issue Links

          Activity

            People

              ant Anton Tarasov (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: