JDK-6557820 : Editable JComboBox inside JTable, keyboard selection doesn't work with JDK 1.6.0
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-05-15
  • Updated: 2011-01-19
  • Resolved: 2007-07-05
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)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Microsoft Windows 2000 [Version 5.00.2195]


A DESCRIPTION OF THE PROBLEM :
In an editable combo box inside a JTable, when using the keyboard, presing enter or the space bar doesn't select the highlighted item. This worked with JDK 1.5.0.08.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Select the editable combo box
click esc to open the drop down list
using the arrow keys highlith one of the items
press enter (or space)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The highlighted item should be selected
ACTUAL -
with enter the list is closed and nothing is selected, with the spacebar nothing happens.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.DefaultCellEditor;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
/*
 * Test.java
 *
 * Created on May 3, 2007, 1:29 PM
 */

/**
 *
 * @author  helm-youngs
 */
public class Test extends javax.swing.JFrame {
    
    /** Creates new form Test */
    public Test() {
        initComponents();
        getContentPane().add(scrollPane);
        pack();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        editableComboBox = new javax.swing.JComboBox();
        scrollPane = new javax.swing.JScrollPane();
        testTable = new javax.swing.JTable();
        
        editableComboBox.setEditable(true);
        editableComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Test");
        testTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
        },
            new String [] {
            "Title 1", "Title 2", "Title 3", "Title 4"
        }
        ));
        TableColumnModel columnModel = testTable.getColumnModel();
        TableColumn tableColumn = columnModel.getColumn(0);
        tableColumn.setCellEditor(new DefaultCellEditor(editableComboBox));
        scrollPane.setViewportView(testTable);        
    }//GEN-END:initComponents
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Test().setVisible(true);
            }
        });
    }
    
// Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox editableComboBox;
    private javax.swing.JScrollPane scrollPane;
    private javax.swing.JTable testTable;
// End of variables declaration//GEN-END:variables
    
}

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

CUSTOMER SUBMITTED WORKAROUND :
using alt+up or down arrow selects the highlited item.

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

Comments
EVALUATION Really, it is a duplicate of 6559152. The bug is reproducible since jdk6 b96. I tried the test case under 6u3 and under the latest jdk7 build. The bug didn't appear. You can select an item with the ENTER key. However, under any jdk (5, 6, 7) you cannot select items with the SPACE key. If a combo box is editable, pressing of the SPACE key just types the space character. It is a feature of combo box.
05-07-2007

EVALUATION Looks like a duplicate of 6559152. Can you please confirm ###@###.###?
29-06-2007