JDK-4760073 : Table combox cell does not handle mouse click consistently.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_98
  • CPU: x86
  • Submitted: 2002-10-08
  • Updated: 2006-04-26
  • Resolved: 2006-04-26
Related Reports
Duplicate :  
Description
Name: sv35042			Date: 10/08/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 :
Windows 98 [Version 4.10.2222]

A DESCRIPTION OF THE PROBLEM :
JTable with a combobox column and other columns

   + click on a non-combobox cell, then click on right side
of the table combo box cell, the combobox will drop down.
But if click on a combobox cell, then click on the right
hand side of another combobox cell, the combo box will not
show up, it just show as being editted.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please check the description, has all information.

EXPECTED VERSUS ACTUAL BEHAVIOR :
The combobox cell should behave the same all the time, no
matter where user click before clicking it.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;

public class ComboEditorTest extends JFrame {
	
	// fill in table values
	public static String[]	colNames = {
		"no.", "methode", "id 1", "id2", "sample weight", "unit"
	};
	public static Object[][]		data = {
		{
			new Integer(1), "chlorid", "123456789012345678901234",
				"4711 - 0815", new Float(7.2348), "g"
		}, {
			new Integer(2), "chlorid", "123456789012345678901234",
				"4711 - 0815", new Float(7.2348), "g"
			}, {
				new Integer
(3), "chlorid", "123456789012345678901234",
					"4711 - 0815", new Float(7.2348), "g"
			}
	};
	
	public ComboEditorTest() {
		JTable table = new JTable(data, colNames);
		
		JScrollPane scrollPane = new JScrollPane(table);
		scrollPane.setPreferredSize(new Dimension(450, 100));
		getContentPane().add(scrollPane);
		JButton btntest = new JButton("Click me");
		getContentPane().add(btntest, BorderLayout.SOUTH);
		
		// use a combo box as cell renderer for the 2nd column
		JComboBox cb = new JComboBox();
		cb.setEditable(true);
		cb.addItem("chlorid");
		cb.addItem("HCl");
		cb.addItem("water");
		cb.addItem("NaCl");
		cb.addItem("crystall water");
		cb.addItem("anything");
		TableColumn col = table.getColumnModel().getColumn(1);
		col.setCellEditor(new DefaultCellEditor(cb));
		
		
		addWindowListener(new WindowAdapter()  {
			public void windowClosing(WindowEvent evt)	{
				System.exit(0);
			}
		});
	}
	
	public static void main(String[] args)	{
		ComboEditorTest test = new ComboEditorTest();
		test.pack();
		test.setVisible(true);
	}
	
}

---------- END SOURCE ----------
(Review ID: 143253) 
======================================================================

Comments
EVALUATION I usually prefer to close newer bugs as duplicates of older ones, but in this case there's a newer bug with more information on the issue and a higher priority. As such, closing as a duplicate of 6210779.
26-04-2006

EVALUATION I have seen this behavior myself many times with SwingSet2. This deserves further investigation. ###@###.### 2002-10-18 These comments, from an external developer who looked into the bug, may be helpful in fixing it: "I did try to do some debugging and found that the problem occurs because the table gets focus right after the combobox gets focus, thus closing or not letting the list open up on the click." ###@###.### 2003-07-14
14-07-2003