JDK-6246461 : JComboBox does not trigger any FocusEvent when in editable mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-03-26
  • Updated: 2010-04-02
  • Resolved: 2005-03-30
Related Reports
Duplicate :  
Description
I am adding a JComboBox to a JFrame and I have added a FocusListener to it. I expect the component to trigger FocusGained event when gaining focus. But when the JcomboBox is editable, it does not trigger any focus events when it gains / loses focus. When it is changed to non-editable, it triggers the focus events properly. This is incorrect. Support for FocusEvent is a basic functionality and hence must be supported.

This is reproducible on all platforms atleast since 1.4. Reproducible on Mustang-b28 also.

I have attached a sample test. Execute the sample test. Press TAB key repeatedly. Focus traverses through all the components. Check whether any focus event is triggered on the console (especially with source as JComboBox). Click the button to toggle the editability of JComboBox. Try the above operation when combo box is non-editable. You would notice that the combo box does not trigger any focus events when in editable mode.
###@###.### 2005-03-26 13:54:22 GMT

Comments
EVALUATION JComboBox is a composite component. To accomplish what you want when editable, you need to add your listener to the editor component: comboBox.getEditor().getEditorComponent().addFocusListener(... Closing as a duplicate of 4144505. ###@###.### 2005-03-30 21:05:56 GMT
30-03-2005