Name: jk109818 Date: 11/13/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows 98 [Version 4.10.2222]
A DESCRIPTION OF THE PROBLEM :
The cell does not edit properly. The display screw up and
partially hightlight of text was shown (couple characters
were highlighted, the rest is not). Many times, users have
to click twice for it to work. Very inconsistently.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the attached code
2.Click on clickme twice (once may do)
3.Click on the 2nd col(methode) and row 3
4. Click on the 2nd col (methode) and row 2
5. Click on the 2nd col (methode) and row 2 (again)
6. Click on the 2nd col (methode) and row1
7. Click on any row of 2nd column once or twice
EXPECTED VERSUS ACTUAL BEHAVIOR :
When click 1 time, the cell will be editable, and the cursor
will be either:
1) befire first character
2) at the click point
3) at the last chacter
4) the cell must be edited
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
public class ComboEditorTest extends JFrame {
// fill in table values
public static String[] colNames = {
"no.", "methode", "id 1", "id2", "sample weight", "unit"
};
public static Object[][] data = {
{
new Integer(1), "chlorid", "123456789012345678901234",
"4711 - 0815", new Float(7.2348), "g"
}, {
new Integer(2), "chlorid", "123456789012345678901234",
"4711 - 0815", new Float(7.2348), "g"
}, {
new Integer(3), "chlorid", "123456789012345678901234",
"4711 - 0815", new Float(7.2348), "g"
}
};
public ComboEditorTest() {
JTable table = new JTable(data, colNames);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(450, 100));
getContentPane().add(scrollPane);
JButton btntest = new JButton("Click me");
getContentPane().add(btntest, BorderLayout.SOUTH);
// use a combo box as cell renderer for the 2nd column
JComboBox cb = new JComboBox();
cb.setEditable(true);
cb.addItem("chlorid");
cb.addItem("HCl");
cb.addItem("water");
cb.addItem("NaCl");
cb.addItem("crystall water");
cb.addItem("anything");
TableColumn col = table.getColumnModel().getColumn(1);
col.setCellEditor(new DefaultCellEditor(cb));
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
}
public static void main(String[] args) {
ComboEditorTest test = new ComboEditorTest();
test.pack();
test.setVisible(true);
}
}
---------- END SOURCE ----------
(Review ID: 164745)
======================================================================