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

REGRESSION: Modified editable JComboBox in Windows LAF does not release focus.

XMLWordPrintable

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



      Name: jk109818 Date: 04/24/2002


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]
      Service Pack 2


      A DESCRIPTION OF THE PROBLEM :
      When an editable JComboBox is modified using the keyboard
      instead of the mouse, it's FocusListener will cause it to
      reaquire focus when handling a FocusLost event. Note that
      this only happens with using the Windows LookAndFeel
      because WindowsComboBoxUI$WindowsComboBoxEditor.setItem()
      calls selectAll(). The following trace shows the sequence:

      java.lang.Exception: Stack trace
              at java.lang.Thread.dumpStack(Thread.java:1071)
              at java.awt.Component.requestFocus
      (Component.java:5862)
              at javax.swing.JComponent.requestFocus
      (JComponent.java:1101)
              at
      javax.swing.plaf.basic.BasicComboBoxEditor.selectAll
      (BasicComboBoxEditor.java:82)
              at
      com.sun.java.swing.plaf.windows.WindowsComboBoxUI$WindowsCom
      boBoxEditor.setItem(WindowsComboBoxUI.java:99)
              at javax.swing.JComboBox.configureEditor
      (JComboBox.java:1335)
              at
      javax.swing.plaf.basic.BasicComboBoxUI$ListDataHandler.conte
      ntsChanged(BasicComboBoxUI.java:549)
              at javax.swing.AbstractListModel.fireContentsChanged
      (AbstractListModel.java:100)
              at javax.swing.DefaultComboBoxModel.setSelectedItem
      (DefaultComboBoxModel.java:88)
              at javax.swing.JComboBox.actionPerformed
      (JComboBox.java:1250)
              at
      javax.swing.plaf.basic.BasicComboBoxUI$EditorFocusListener.f
      ocusLost(BasicComboBoxUI.java:1562)
              at java.awt.AWTEventMulticaster.focusLost
      (AWTEventMulticaster.java:168)
              at java.awt.Component.processFocusEvent
      (Component.java:4927)
              at java.awt.Component.processEvent
      (Component.java:4809)
              at java.awt.Container.processEvent
      (Container.java:1380)
              at java.awt.Component.dispatchEventImpl
      (Component.java:3526)
              at java.awt.Container.dispatchEventImpl
      (Container.java:1437)
              at java.awt.Component.dispatchEvent
      (Component.java:3367)
              at java.awt.KeyboardFocusManager.redispatchEvent
      (KeyboardFocusManager.java:1700)
              at
      java.awt.DefaultKeyboardFocusManager.typeAheadAssertions
      (DefaultKeyboardFocusManager.java:709)
              at
      java.awt.DefaultKeyboardFocusManager.dispatchEvent
      (DefaultKeyboardFocusManager.java:442)
              at java.awt.Component.dispatchEventImpl
      (Component.java:3396)
              at java.awt.Container.dispatchEventImpl
      (Container.java:1437)
              at java.awt.Component.dispatchEvent
      (Component.java:3367)
              at java.awt.EventQueue.dispatchEvent
      (EventQueue.java:445)
              at com.isscorp.ISSAppl$MyEventQueue.dispatchEvent
      (ISSAppl.java:163)
              at
      java.awt.EventDispatchThread.pumpOneEventForHierarchy
      (EventDispatchThread.java:190)
              at
      java.awt.EventDispatchThread.pumpEventsForHierarchy
      (EventDispatchThread.java:144)
              at java.awt.EventDispatchThread.pumpEvents
      (EventDispatchThread.java:138)
              at java.awt.EventDispatchThread.pumpEvents
      (EventDispatchThread.java:130)
              at java.awt.EventDispatchThread.run
      (EventDispatchThread.java:98)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.While using the Windows LookAndFeel, create a JFrame
      containing an editable JComboBox and make the JFrame
      visible.
      2.Using the keyboard, modify the value of the JComboBox.
      3.Tab out of the field. The field will re-aquire focus.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Focus should move to the next focusable field. Instead,
      the current field re-aquires focus.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class MyTest extends JFrame {

      // Pass "YES" to create editable JComboBox, or "NO" to create
      // an uneditable JComboBox.
      public static void main(String args[]) {
      try {
      UIManager.setLookAndFeel
      (UIManager.getSystemLookAndFeelClassName());
      }
      catch (Exception e) {
      System.out.println(e);
      }

      MyTest myTest = new MyTest(args[0].equalsIgnoreCase("yes"));
      myTest.setVisible(true);
      }

      public MyTest(boolean editable) {
      super("Test");

      String options[] = new String[] {"One", "Two"};
      JComboBox cb = new JComboBox(options);
      cb.setEditable(editable);
      getContentPane().add(cb, BorderLayout.WEST);

      JTextField tf = new JTextField(10);
      getContentPane().add(tf, BorderLayout.EAST);

      pack();
      }
      }
      ---------- END SOURCE ----------

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

      (Review ID: 145137)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: