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

Table combox cell does not handle mouse click consistently.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs

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

            shickeysunw Shannon Hickey (Inactive)
            svioletsunw Scott Violet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: