JDK-4518907 : CellEditorRemover active only after first edit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 2001-10-24
  • Updated: 2001-10-26
  • Resolved: 2001-10-26
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 10/24/2001


E:\jdk1.4\bin>java -version
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)



  To reproduce:
1.Take a table of your choice. Make sure at least one cell is
editable and there is at least one other component in the
table's root window. (That's the szenario where cellEditorRemover
should cancel an edit when the focus is transfered to some
component that's not a child of the table).

2. Edit a cell, click on that other component. The editing is cancelled.

3. Again edit a cell, click on the other component. The editing is _not_
cancelled.

Analysis:

JTable's editorRemover is added as a listener to the
KeyboardFocusMangager in editCellAt(..) only when it is null (then
the remover is created and added). It is removed as listener in
removeEditor, but it is not nulled in that method. Consequently it
is listening to focusManager propertyChanges only on the very first
edit after creation.

  Fix:
A. Either null the editorRemover in removeEditor after removing it as
listener from focusManager
B. or decouple the logic of creation of editorRemover from adding it as
listener.

I suspect you have to do A as focusManagers might change between calls
to editCellAt.

Response from bug submitter: -

take the SwingSet2 as test case.
(Review ID: 134285) 
======================================================================

Comments
WORK AROUND Name: gm110360 Date: 10/24/2001 Workaround: as editorRemover is private there is nothing to do except define another var and copy and paste the cellEditorRemover and apply B. ======================================================================
11-06-2004

EVALUATION java.swing.JTable indeed does need to set 'editorRemover' to null after calls to removePropertyChangeListener("focusOwner", editorRemover); in both removeNotify() and in removeEditor(). ###@###.### 2001-10-24
24-10-2001