JDK-4497301 : REGRESSION: JComboBox can't be selected with the Mouse in a modal dialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2001-08-28
  • Updated: 2002-07-26
  • Resolved: 2002-07-26
Related Reports
Duplicate :  
Relates :  
Description

Name: rmT116609			Date: 08/28/2001


java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)


Please run the following program:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JComboBoxBug
{
	static JDialog dialog=new JDialog();
	static JLabel infoLabel=new JLabel();
	
	public static void main (String args[])
	{
		dialog.setTitle("JComboBoxBug");
		dialog.setModal(true);

		JComboBox box=new JComboBox();
		for(int i=1;i<5;i++)
		{
			// add some entries
			box.addItem("Entry "+i);
		}
		Container cont=dialog.getContentPane();
		cont.setLayout(new BorderLayout());
		
		JPanel centerPanel=new JPanel();
		JPanel southPanel=new JPanel();
		JButton okButton=new JButton("OK");
		centerPanel.add(infoLabel);
		centerPanel.add(box);
		southPanel.add(okButton);
		okButton.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent evt)
				{
					dialog.hide();
				}
			});
		cont.add(BorderLayout.CENTER, centerPanel);
		cont.add(BorderLayout.SOUTH, southPanel);
		infoLabel.setText("Please select something using your mouse and then click ok.");
		dialog.pack();
		dialog.show();
 infoLabel.setText("Now try selecting something different with your mouse again. It won't work in JDK 1.4 Beta1/2 (regression). JDK 1.3.1 works fine. Key-Selection still works.");
		dialog.pack();
		dialog.show();
		System.exit(0);
	}
}

The used JComboBox can't be selected with the mouse anymore when the modal
dialog is displayed for the second time. Keyboard-Selection (Cursor-up/down)
still works as expected.

This is a regression from jdk1.3.1 where this code works without problems.
(Review ID: 130838) 
======================================================================

Comments
EVALUATION Name: pzR10082 Date: 09/05/2001 When the modal dialog is displayed the second time, heavyweight Window beneath combo popup doesn't receive mouse events. Component.dispatchEvent() is not even called. The events seem to get lost somewhere. ###@###.### 2001-09-05 ====================================================================== This bug has been introduced between b55 (03/09/01) and b56 (03/14/01). This seems to be another heavy weight popup bug. If the combo popup is made to be lightweight by making the frame larger on the first dialog, the problem goes away. This bug was introduced as a side effect for the fix to 4410329. In that fix, the hide() method of the Popup.HeavyWeightWindow was removed. When hide() is reintroduced it fixes the bug. Perhaps this workaround should be re-introduced but care should be made to ensure that 4410329 does not regress. ###@###.### 2001-09-10 Name: pzR10082 Date: 09/21/2001 It appears that the method Popup.HeavyWeightWindow.hide() can be safely restored. Bug 4410329 was likely addressed by fix for 4490344. ###@###.### 2001-09-21 ====================================================================== Name: pzR10082 Date: 09/25/2001 This seems an AWT problem that can only be worked around in Swing. The heavyweight window shouldn't be receiving no mouse events at all. ###@###.### 2001-09-25 ====================================================================== Assigning to Swing for their evalutation. A Win32 problem only. ###@###.### 2001-09-25 We had at one point been invoking removeNotify on the Window that was displaying the Popup. Since this seemed like a bad thing, we removed it, and it appears this case no longer works. We can add the removeNotify back, but since the javadoc indicates we shouldn't be invoking this method directly, it doesn't seem right. ###@###.### 2001-09-25 The heavyweight created for the combobox is receiving native win32 events. For some reason AWT events seem to be lost. Actually it appears only mouse events are lost as keyboard input works fine. The second call to pack() seems to cause the problem. ###@###.### 2001-09-25 May no longer be reproducible in hopper build 11, although I don't know what would have fixed it offhand. See Comments. ###@###.### 2002-05-15 If this is not already addressed in Hopper, we should fix it in Tiger (JDC). ###@###.### 2002-07-25 No longer reproducible in Hopper. ###@###.### 2002-07-26
15-05-2002

SUGGESTED FIX Name: pzR10082 Date: 09/21/2001 *** /tmp/geta4903 Fri Sep 21 14:59:18 2001 --- Popup.java Wed Sep 19 13:02:26 2001 *************** *** 209,214 **** --- 209,225 ---- paint(g); } + public void hide() { + super.hide(); + /** We need to call removeNotify() here because hide() does + * something only if Component.visible is true. When the app + * frame is miniaturized, the parent frame of this frame is + * invisible, causing AWT to believe that this frame + * is invisible and causing hide() to do nothing + */ + removeNotify(); + } + public void show() { super.show(); this.pack(); ###@###.### 2001-09-21 ======================================================================
21-09-2001