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

REGRESSION: Focus not returning to JTextField after using JMenu with Windows L&F

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • client-libs



      Name: jk109818 Date: 01/02/2002


      FULL PRODUCT VERSION :
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed
      mode)

      FULL OPERATING SYSTEM VERSION : Windows 2000 Pro




      A DESCRIPTION OF THE PROBLEM :
      After popping up a reguar JMenu in a JMenuBar, the focus is
      not returned to the previously selected JTextField. This
      only occurs with the Windows Look and Feel; when I use the
      default (Metal, right?) L&F the focus is properly restored.

      Is the Windows L&F JMenuBar using temporary focus properly?

      This was replicated in a minimal JFrame app with a single
      JMenuBar, JMenu, and JTextField.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run SwingSet2 from j2sdk1.4-beta3 release
      2. Change L&F to Windows
      3. Click in the "frame title" edit box
      4. Click on the "File" menu to display file menu
      5. Click on the "File" menu header again to dismiss it
      6. Notice that the "frame title" edit box isn't focused
      7. Change L&F to Java L&F
      8. Repeat steps 3-5
      9. The "frame title" edit box is still focused

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      At step 6, I expect the frame title edit box to be
      focused. It isn't.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // This was created with NetBeans 3.3

      package test;

      import javax.swing.UIManager;

      public class TempFocusTest extends javax.swing.JFrame {

          /** Creates new form TempFocusTest */
          public TempFocusTest() {
              initComponents();
          }

          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of
      this method is
           * always regenerated by the Form Editor.
           */
          private void initComponents() {
              jTextField1 = new javax.swing.JTextField();
              jMenuBar1 = new javax.swing.JMenuBar();
              jMenu1 = new javax.swing.JMenu();
              jMenuItem1 = new javax.swing.JMenuItem();

              addWindowListener(new java.awt.event.WindowAdapter
      () {
                  public void windowClosing
      (java.awt.event.WindowEvent evt) {
                      exitForm(evt);
                  }
              });

              jTextField1.setText("jTextField1");
              getContentPane().add(jTextField1,
      java.awt.BorderLayout.CENTER);

              jMenu1.setText("Menu");
              jMenuItem1.setText("Item");
              jMenu1.add(jMenuItem1);
              jMenuBar1.add(jMenu1);
              setJMenuBar(jMenuBar1);

              pack();
          }

          /** Exit the Application */
          private void exitForm(java.awt.event.WindowEvent evt) {
              System.exit(0);
          }

          /**
          * @param args the command line arguments
          */
          public static void main(String args[]) {
              try {
                  UIManager.setLookAndFeel
      (UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
              }
              new TempFocusTest().show();
          }


          // Variables declaration - do not modify
          private javax.swing.JMenu jMenu1;
          private javax.swing.JMenuItem jMenuItem1;
          private javax.swing.JTextField jTextField1;
          private javax.swing.JMenuBar jMenuBar1;
          // End of variables declaration

      }

      ---------- END SOURCE ----------

      Release Regression From : 1.3.1_02
      The above release value was the last known release where this
      bug was knwon to work. Since then there has been a regression.

      (Review ID: 137826)
      ======================================================================

            peterz Peter Zhelezniakov
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: