FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08) Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I am trying to achieve Excel editing behavior in a JTable. I had everything working in JDK1.4 and then it broke when going to JDK1.5. Apparently, the JDK has changed slightly. The particular Excel behavior that is broken is when double clicking a cell to start editing. The cell editor is a JTextField. In JDK1.4, double clicking the cell would start the edit process causing my JTextField cell editor to get shown and the JDK would forward the MouseEvent with a click count of 1 to the JTextField. The JTextField would respond to the MouseEvent with click count of 1 and just position the text cursor as desired. This is just like Excel.
Now in JDK1.5 with no other code changes, the double click starts the edit process and the MouseEvent is forwarded to the JTextField BUT this time with a click count of 2. The JTextField responds to this MouseEvent with click count of 2 by highlighting whatever text is in the JTextField. I don't want this initial highlight to take place.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run included test program with JDK1.5. Just double click any cell over the text inside that cell.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect for the edit process to start, the cell editor to be added to the JTable for that cell and the text cursor to be positioned where the doble click took place with no text selection/highlighting.
ACTUAL -
Everything occurs correctly except the contents of the cell is highlighted from the double click event
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
public class Untitled1 {
public static void main(String[] args)
{
JFrame f = new JFrame("Big Table Model");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BigTableModel tm = new BigTableModel();
JTable t = new JTable(tm);
JScrollPane sp = new JScrollPane(t);
f.getContentPane().add(sp);
f.pack();
f.setVisible(true);
}
public static class BigTableModel extends AbstractTableModel {
public boolean isCellEditable(int row,int column)
{
return(true);
}
public Object getValueAt(int row,int column)
{
return("" + row + "," + column);
}
public int getColumnCount()
{
return(10);
}
public int getRowCount()
{
return(1000);
}
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.2_07
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-04-29 10:32:10 GMT