-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.2.2
-
generic
-
generic
Name: vi73552 Date: 06/25/99
JTextfield-based DefaultCellEditors remain active in JTables
after the table cell has lost focus. Several similar bug postings existed for JComboBox-based CellEditors, but none for
JTextfields.
To reproduce bug:
double click on a table cell to gain editing focus.
click on any other ui component to make the editor lose focus.
The editor will remain.
this test code will reproduce the error pretty simply.
import javax.swing.*;
import javax.swing.table.*;
public class Test extends JFrame
{
public Test()
{
JPanel panel = new JPanel();
JPanel mainPanel = new JPanel();
JButton button = new JButton("Button");
JTable table = new JTable();
JScrollPane sPane = new JScrollPane(table);
table.setModel(new MyModel());
DefaultCellEditor editor = new DefaultCellEditor(new JTextField());
TableColumnModel tcModel = table.getColumnModel();
TableColumn tColumn = tcModel.getColumn(0);
tColumn.setCellEditor(editor);
panel.add(button);
mainPanel.add(panel);
mainPanel.add(sPane);
getContentPane().add(mainPanel);
pack();
show();
}
public class MyModel extends AbstractTableModel
{
protected String[] data = new String[5];
public MyModel()
{
for(int i = 0; i < 5; i++)
{
data[i] = "data: " + i;
}
}
public boolean isCellEditable(int rowIndex, int columnIndex)
{
return true;
}
public int getColumnCount()
{
return 1;
}
public int getRowCount()
{
return 5;
}
public String getColumnName(int col)
{
return "Focus Bug";
}
public Object getValueAt(int row, int col)
{
return data[row];
}
public void setValueAt(Object value, int row, int col)
{
data[row] = (String) value;
}
}
public static void main(String args[])
{
new Test();
}
}
"java -version"
java version "1.2"
Classic VM (build JDK-1.2-V, native threads)
"java -fullversion"
java full version "JDK-1.2-V"
(Review ID: 84859)
======================================================================
- duplicates
-
JDK-4460382 For Jdk1.4, the table editors for JTable do not work.
- Closed