Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6557820

Editable JComboBox inside JTable, keyboard selection doesn't work with JDK 1.6.0

    XMLWordPrintable

Details

    • b96
    • 6
    • x86
    • windows_xp

    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.

      Attachments

        Issue Links

          Activity

            People

              mlapshin Mikhail Lapshin (Inactive)
              ryeung Roger Yeung (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: