Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Don't understand defaultCellEditor for Float values

843805Nov 24 2006 — edited Nov 27 2006
I have a JTable which has a column of float values. The column class is set to Float, and the (simplified) getValueAt method looks like this:

public Object getValueAt(int row, int col) {
return new Float(floatValues[row]);
}

The getColumnClass method returns a Float.

The defaultCellEditor works OK, except that if the column entry contains a single zero, for instance, and you click on the cell or move to the cell using hte cursor keys, then if you type a 1, the value displayed becomes "0.01". If you type ".1", the n it displays "0.0.1", which requires futher editing. The only way around it is to delete or highlight the existing values before entering.

Is there a way to change this behaviour without writing a custom cell editor? It seems the default behaviour isn't right, unless I've missed something obvious.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2006
Added on Nov 24 2006
7 comments
220 views