Thanks, that was helpful. I decided to fire up Excel and see what it did. With Excel, the width of the cell is expanded to accomodate the size of the number, a JTable cell does not expand. In Excel it is clear to the user what the number is. I can't of course "just store what I want the user to see." It's not even just a matter of numerical accuracy, floating point numbers do not have an exact representation, a column of Double.class cannot guarantee a number will be displayed with two digits, unless it is converted to a
String. That of course, is what the cell renderer is for. If I used a String column, I'd have to reimplement the type checking that is done by default with a column of type double. It looks to me like the code that you supplied would help with that as well. Also, I think it might address my other question, which was how to prevent entry of a number which would make the sum of the column exceed a defined value.
BTW the first mention of the
word 'bug' was by Paul. What I said was that if a number 1.666666666 is stored in a cell (displayed as 1.67) and the user clicks in the cell to edit it and sees 666667 that it would be confusing. I was hoping I could modify the way the cell editor rendered the number. Though I think now it is better simply to get the number left-justified. I was 'triple-clicking' which selects the number. That is when it right-justifies. Now I have something concrete, I can try getting some of the other behavior I am supposed to implement. So thanks again.