> hi,
>
[quoted text clipped - 5 lines]
> I'd rather see 3 (1.0 should be delete : in other words type sould
> replace selection (that's the way Excel operates).
One way to do it is to override JTable's editCellAt(...) method:
public boolean editCellAt(int row, int column, EventObject e) {
boolean res = super.editCellAt(row, column, e);
Component c = this.getEditorComponent();
if (c instanceof JTextComponent) {
( (JTextField) c).selectAll();
}
return res;
}
This will select the old content the instant you start editing the cell,
with the result that it is immediately overwritten with the new content
your typing.

Signature
Dag.
oulan bator - 20 Dec 2005 08:18 GMT
Thanks a lot, it works fine, and overall, it's really smart !
oulan bator - 20 Dec 2005 08:34 GMT
one detail for others readers: I've change a litlle bit his code :
if (c instanceof JTextField) {
( (JTextField) c).selectAll();
it's more secure
Dag Sunde - 20 Dec 2005 08:35 GMT
> Thanks a lot, it works fine, and overall, it's really smart !
Just remember that it will stop working for a column if you
introduce a custom cell-editor that is based on something
else than JTextComponent...

Signature
Dag.
oulan bator - 20 Dec 2005 08:50 GMT
dag:
yes you are right, I think JTextComponent is even better.
For other customs editors, the "bug" does not apply ...