JDK-6513874 : JComboBox in DefaultCellEditor does not always show popup when beginning edit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-01-17
  • Updated: 2011-02-16
  • Resolved: 2007-01-17
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
JComboBox used as the editorComponent of a DefaultCellEditor in a JTable does not always show its popup when it begins editing a cell.

When editing of a cell in a JTable begins, the JComboBox of that cell's DefaultCellEditor only displays its popup if the mouse click that caused the editing to begin does not also cause that same DefaultCellEditor to stop editing another cell.

This problem exists using the default L&F, Windows XP L&F, and Aqua L&F.  It may not be a L&F-related problem.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the attached ComboBoxCellEditorDemo.
2. Click the cell in the second row, second column (initial value of that cell is "L"). The combo box popup appears, as expected.
3. Without dismissing the popup, click the cell in the first row, second column (initial value of that cell is "M"). ***The combo box popup does not appear!***
4. Click that same cell again. Now the popup appears.
5. Click that same cell a third time. The popup disappears.
6. Click the cell in the second row, second column. ***The combo box popup does not appear!***
7. Click the cell in the first row, second column. ***The combo box popup does not appear!***
8. Repeat steps 6 and 7 until you're blue in the face. If you pay close attention, you can notice the popup is visible for a split second when clicking a cell.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Clicking on a cell in a JTable whose cell editor is a DefaultCellEditor using a JComboBox should always cause the combo box popup to appear.  The one exception is when the popup is already visible and the *same* cell is clicked again; in this case, the popup should simply be hidden.
ACTUAL -
Clicking on a cell in a JTable whose cell editor is a DefaultCellEditor using a JComboBox does NOT cause the combo box popup to appear if that DefaultCellEditor was editing a different cell when the click occurred.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;

public class ComboBoxCellEditorDemo {

	public static void main(String[] args) throws Exception {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.setLayout(new BorderLayout());
		JTable table = new JTable(new Object[][] { { "John Jackson", "M" }, { "Jack Johnson", "L" } }, new Object[] { "Name", "Size" });
		table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(new JComboBox(new Object[] { "S", "M", "L", "XL" })));
		table.setRowHeight(20);
		frame.add(new JScrollPane(table));
		frame.pack();
		frame.setVisible(true);
	}

}

---------- END SOURCE ----------

Comments
EVALUATION This is a duplicate of 6210779.
17-01-2007