-
Bug
-
Resolution: Fixed
-
P4
-
1.3.1, 1.4.0
-
hopper
-
generic, x86, sparc
-
generic, solaris_2.6, solaris_8, windows_95, windows_98, windows_nt
-
Verified
Name: gm110360 Date: 09/17/2001
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 the problem, run the attached program, enter data into a cell, and
then click on another UI component. The data that was entered is now gone.
This happens consistently the first time data is entered into a cell and the
table loses focus before the edit operation is completed.
Repeat the operation, double-click on a cell, enter some data, and then click
on another UI component. This time, the data remains, but the CellEditor
remains active and the edit operation is not completed. If you select the
Print Function, it is apparent that the entered data was never saved.
The second aspect of the problem was reported against 1.2.2 & 1.4 beta. It
also exists in 1.3. Bugs 4460382 is closed and the problem is reported fixed
in merlin - Beta 2. Well, apparently not. In fact, the problem with the
CellEditor has another aspect to it right now.
I have not been able to get any of the supposed workarounds to work. There
have been comments that this would get fixed in 1.4 - my fear is that since it
has been closed (I believe in error), the problem will slip through the cracks.
Thanks.
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class FrameNTable extends JFrame {
JTable table, table2, table3;
String[] columnNames = {"String", "String", "String"};
Object[][] data = { {null, null, null},
{null, null, null},
{null, null, null} };
public FrameNTable() {
String version = System.getProperty("java.specification.version");
System.out.println("Java specification version = " + version );
createGUI();
pack();
setVisible(true);
}
private void createGUI() {
JPanel contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout());
// create the JTable
TableModel tableModel = new MyTableModel();
table = new JTable(tableModel);
contentPane.add(table, BorderLayout.CENTER);
// add some other components for variety
JPanel panel = new JPanel();
JTextField textField1 = new JTextField("Field 1");
JTextField textField2 = new JTextField("Field 2");
panel.add(textField1);
panel.add(textField2);
JButton button = new JButton("Print");
panel.add(button);
contentPane.add(panel, BorderLayout.SOUTH);
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
System.out.print(data[i][j] + " ");
}
System.out.println();
}
}
});
}
class MyTableModel extends AbstractTableModel {
public MyTableModel () {
}
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
}
public Class getColumnClass(int col) {
return java.lang.String.class;
}
public boolean isCellEditable(int row, int col) {
return true;
}
}
public static void main (String[] args) {
FrameNTable frame = new FrameNTable();
}
}
(Review ID: 132040)
======================================================================
- duplicates
-
JDK-4648147 j table will not trap the first edit.
-
- Closed
-
-
JDK-4671123 REGRESSION: calling stopCellEditing() does not set value after first time
-
- Closed
-
-
JDK-4518907 CellEditorRemover active only after first edit
-
- Closed
-
-
JDK-4480264 JTable cell editor lost focus bug in SwingSet2 demo
-
- Closed
-
- relates to
-
JDK-4330950 Lost newly entered data in the cell when resizing column width
-
- Closed
-
-
JDK-4709394 1.4 REGRESSION: JTable does not take entered data.
-
- Resolved
-
-
JDK-4372105 When edditing cell in JTable, the cell have to lose focus to accept changes.
-
- Closed
-