JDK-4709394 : 1.4 REGRESSION: JTable does not take entered data.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.1,1.4.2
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_98,windows_2000
  • CPU: x86
  • Submitted: 2002-06-28
  • Updated: 2002-07-19
  • Resolved: 2002-07-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 rcFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description

Name: gm110360			Date: 06/27/2002


FULL PRODUCT VERSION :
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)



A DESCRIPTION OF THE PROBLEM :
JTable does not takes keyboard entered value when clicking on
other component after input.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Click on the first table cell
2.Enter "abc"
3.Click on button "jButton1"
4.The value "abc" disappear from the table.

Note that after step 2, click on other cell of the table,
and the value "abc" will be "accepted" into the table.

EXPECTED VERSUS ACTUAL BEHAVIOR :
The table should takes the value and no enter key or
anything is needed for this.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*
 * TableTest.java
 *
 * Created on June 27, 2002, 5:10 PM
 */

/**
 *
 * @author  vy2
 */
public class TableTest extends javax.swing.JFrame {

    /** Creates new form TableTest */
    public TableTest() {
        initComponents();
    }

    /** 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() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        
        getContentPane().setLayout(null);
        
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {null},
            {null},
            {null},
            {null}
        },
        new String [] {
            "Title 1"
        }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class
            };
            
            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);
        
        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(30, 20, 475, 210);
        
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jButton1.setBounds(70, 275, 81, 26);
        
        pack();
        java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(new java.awt.Dimension(800, 600));
        setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
    }

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        new TableTest().show();
    }


    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton jButton1;
    // End of variables declaration

}

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

CUSTOMER WORKAROUND :
Press enter after enter the value, or click inside the table.

Release Regression From : 1.3.1_03
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 158595) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper-rc FIXED IN: hopper-rc INTEGRATED IN: hopper-rc
14-06-2004

EVALUATION This behaviour is a result of JTable.CellEditorRemover which listens for focus losses on JTable and unconditionally cancels edits when JTable loses focus. Handling this properly would involve opening API so that developers can customize what happens when the table loses focus. For now, one solution can be to try to stop the editing (committing it) and only cancelling if that fails. Note that in the JDC comments for 4503845, Kleopatra has provided lots of useful discussion on the issue. Her website at http://www.mycgiserver.com/~Kleopatra/swing/table/merlinedit.html also has some possible solutions. ###@###.### 2002-07-11 Here's the final intended solution to be putback for hopper RC: CellEditorRemover will be changed to respond only to permanent focus changes. That way, it will not stop editing when focus goes temporarily to a UI item such as a menu. Additionally, it will be changed to first stop editing, and if that fails, then cancel it. Lastly, a client property, "terminateEditOnFocusLost" will be added to JTable, that can be set to Boolean.FALSE to turn off this behavior. In the future, API should be added to give developers more control. ###@###.### 2002-07-11 Unfortunately, although the solution outlined above seems ideal, there is a concern of breaking backwards compatibility, especially in the RC of a dot dot release. For safety, the new behavior will be turned off by default. JTable will do absolutely nothing on focus lost. The client property "terminateEditOnFocusLost" can be used to turn it on as described above. In a beta for the next release, Mantis, we should turn this behavior on by default. ###@###.### 2002-07-15 Just a short addendum on how to turn on the new 'commit or cancel' behavior: table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); ###@###.### 2002-07-16 Final note on this issue. A new RFE, 4724980, has been created to request a flexible API that will allow developers to customize the behavior of JTable on focus losses. ###@###.### 2002-08-01
01-08-2002