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

After Clicking in JComboBox Table Cell, Arrow and Enter Key cannot select.

XMLWordPrintable

    • generic, x86
    • generic, windows_98

      Name: jk109818 Date: 03/12/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 :
      Code is a JTable with a JComboBox column and other columns,

         + Use mouse to click on a JComboBox inside a table cell(make sure
      to click on the right to see the drop down box). Use arrow
      down key (from keyboard) to go down the list, then press
      enter. The bug is that the new value selected will not be selected.

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

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The cell should take the new value.

      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: 143252)
      ======================================================================

            alexp Alexander Potochkin (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: