JDK-5100422 : REGRESSION: Editable JComboBox won't hide popup when tabbing out
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-09-10
  • Updated: 2006-04-19
  • Resolved: 2004-12-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u8Fixed 6 b14Fixed
Related Reports
Duplicate :  
Relates :  
Description
Name: gm110360			Date: 09/10/2004


FULL PRODUCT VERSION :
1.5.0-rc-b63

A DESCRIPTION OF THE PROBLEM :
When tabbing out of an editable JComboBox to another control its popup-list will remain visible. Changing focus by clicking on a different control via mouse will hide popup.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open a combobox's popup list. Switch to the textfield using the tabulator key => Popup remains visible
Switch back (Shift+Tab). Switch to the textfield using a mouse click => Popup is hidden

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See above. Popup should be hidden when tabbing out.
ACTUAL -
Popup remains open.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ComboTest {
  public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().setLayout(new java.awt.FlowLayout());
        JComboBox comboBox = new JComboBox(new Object[] {"A", "B"});
        comboBox.setEditable(true);
        frame.getContentPane().add(comboBox);
        frame.getContentPane().add(new JTextField("I wan't more focus!"));
        frame.pack(); frame.setVisible(true);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
hidePopupOnFocusLoss=System.getProperty("java.version").startsWith("1.5");

comboBox.getEditor().getEditorComponent().addFocusListener(new FocusAdapter() {
  public void focusLost(FocusEvent e) {
    if (hidePopupOnFocusLoss) comboBox.setPopupVisible(false);
  }
});

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

(Incident Review ID: 302409) 
======================================================================
###@###.### 11/2/04 18:07 GMT

Comments
SUGGESTED FIX ------- BasicComboBoxUI.java ------- *** /tmp/sccs.GgaabT Tue Sep 21 17:12:53 2004 --- BasicComboBoxUI.java Tue Sep 21 17:11:12 2004 *************** *** 1587,1610 **** (new ActionEvent(editor, 0, "", EventQueue.getMostRecentEventTime(), 0)); } - return; } hasFocus = false; ! // GES, 980818: ! // Note that the second check here is a workaround to bug ! // 4168483. There is a bogus focusLost sent to the ! // ComboBox with isTemporary false when a mediumweight menu ! // is popped up. Until this is fixed in AWT, we make the ! // tradeoff of not popping down mediumweight popups when ! // the combobox loses focus. Although this means that the ! // combobox does not remove such menus when you tab out, ! // it is seen as more desirable than the alternative which ! // is that mediumweight combobox menus dissappear immediately ! // on popup, rendering them completely unusable. ! if ( !e.isTemporary() && comboBox.isLightWeightPopupEnabled()) { ! setPopupVisible(comboBox, false); ! } comboBox.repaint(); } --- 1587,1596 ---- (new ActionEvent(editor, 0, "", EventQueue.getMostRecentEventTime(), 0)); } } hasFocus = false; ! setPopupVisible(comboBox, false); comboBox.repaint(); }
25-09-2004

EVALUATION The problem here is in the early return from the BasicComboBoxUI.focusLost() method. The idea of suggested fix is to remove this return. Also, since bug 4168483 was fixed we are no longer need the workaround for it in this method. ###@###.### 2004-09-21
21-09-2004