JDK-6770445 : Unable to transfer focus with single click when the combobox popup is visible
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6,6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic,windows_2003,windows_xp
  • CPU: generic,x86
  • Submitted: 2008-11-12
  • Updated: 2011-02-16
  • Resolved: 2008-12-25
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows 2003

A DESCRIPTION OF THE PROBLEM :
Until JDK 6, Single click on any swing component when combobox popup is visible hides the combobox popup and the focus is transferred to the component on which the mouse was clicked.

In JDK6 Updated 10, Single click on any component just hides the combobox popup. Another click must be made (once the popup is hidden) to actually transfer the focus.

Also, this issue is happening only when the Look and Feel is set to WindowsLookAndFeel.




STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and Run the provided source code.
2. Click the combo box to show the popup containing options.
3. Now, with the popup being visible, click on the text field.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Popup is hidden and the cursor focus goes to the text field.
ACTUAL -
Popup is hidden but the focus still remains on the combo box.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class TestComboBox extends JFrame {
	
	JComboBox cb = null;
	JTextField tf = null;
		
	public TestComboBox() {
		super("Test Combo");
		
		cb = new JComboBox(new String[]{"one","two","three","four"});
		tf = new JTextField();
		tf.setColumns(10);

		this.getContentPane().setLayout(new FlowLayout());
		this.getContentPane().add(cb);
		this.getContentPane().add(tf);
		
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
	}
	
	public static void main(String[] args) throws Exception {
		
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		
		TestComboBox tc = new TestComboBox();
		
		tc.setSize(500,500);
		tc.setVisible(true);
	}
---------- END SOURCE ----------

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

Comments
EVALUATION Finally it was agreed that we shouldn't fix it because WindowsLaF exactly emulates the native Windows behaviour and it was the goal of the fix for 6646781
25-12-2008

EVALUATION the fix for #6646781 is to be partly rolled back, "PopupMenu.consumeEventOnClose" will be reset again for Windows LaF, Nimbus LaF will not be affected
21-11-2008

EVALUATION One more bug fix contributed to the described problem 6646781:Nimbus L&F : Menu stays open when continously clicked on internal frame icon on Windows & nimbus L&F fix for 4912806 introduced the "PopupMenu.consumeEventOnClose" property but it is fix for 6646781 that set this field to true for the Windows LaF
17-11-2008

EVALUATION UIManager.getBoolean("PopupMenu.consumeEventOnClose") is checked, use UIManager.put("PopupMenu.consumeEventOnClose", false) to switch it off
13-11-2008

EVALUATION This is the result of the fix 4912806, we ask UIManager whether we have to consume event that closes popup or not. For WindowsLaF we do it, this was made to match native apps behaviour.
13-11-2008