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

CellEditorListener.editingCanceled is never called

XMLWordPrintable

    • b26
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_11"
      Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
      Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      When editing of a table cell is canceled the funcion editingCanceled of the registered listener CellEditorListener is not called, but it should be called according to the docs. (Note: The function editingStopped of the same listener is called correctly)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start cell editing then press Esc. "canceled" should be printed on console, but there is no such text (CellEditorListener.editingCanceled is never called). (If you stop editing by pressing Enter for example then "stopped" is printed on console correctly)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "canceled" should be printed on console after canceling cell editing.
      ACTUAL -
      no text is printed on console.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.event.*;
       
      public class BugCellEditorListener extends JFrame
      {
      BugCellEditorListener()
      {
      JTable table = new JTable(5,5);
      table.setPreferredScrollableViewportSize(table.getPreferredSize());
      JScrollPane scrollpane = new JScrollPane(table);
      getContentPane().add(scrollpane);
       
      DefaultCellEditor dce = (DefaultCellEditor)table.getDefaultEditor(Object.class);
      dce.addCellEditorListener( new CellEditorListener()
      {
      public void editingStopped(ChangeEvent e)
      {
      System.out.println("stopped");
      }
       
      public void editingCanceled(ChangeEvent e)
      {
      System.out.println("canceled");
      }
      });
      }
       
      public static void main(String [] args)
      {
      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      JFrame frame = new BugCellEditorListener();
      frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
      frame.pack();
      frame.setLocationRelativeTo( null );
      frame.setVisible(true);
      }
      });
      }
      }


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

      CUSTOMER SUBMITTED WORKAROUND :
      Partial w/a: catch "Esc" with InputMap/ActionMap and call CellEditor.cancelCellEditing. But cell editing is canceled also when the table is resized, so to catch this cancelation the events of resizing should be catched also. (I don't know exactly maybe there are some other ways to cancel cell editing).

            psadhukhan Prasanta Sadhukhan
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: