formatting floats in a table
- From: "farseer" <farseer@xxxxxxxxxxxxx>
- Date: 26 Jun 2005 23:42:58 -0700
Hi,
i have a table whose columns can contain either Strings, Integers, or
Floats. I also allow sorting by clicking on the header of a column.
my question is, i need to display only two decimal places for columns
that display floats. How can i do this and still maintain accurate
sorting for those columns? Currently, it seems most of the formating
functions return Strings, and that may cause the sorting to be
incorrect for columns that are suppose to display numbers.
Also i am trying to do this generically using a custom
TableCellRenderer class i have written. This renderer has a member
variable called "formatString". Basically, when the JTable is
initalized, i read some config info, one of which tells me what columns
need formatting and how they should be formatted. I then instantiate
the TableCellRenderer class, assign the formatString (if required),
then call TableColumn.setCellRenderer.
Now i just need to know how i can apply that formatString to the Value
and still maintain the underlying class type of Value so that i can be
properly sorted....
.
- Follow-Ups:
- Re: formatting floats in a table
- From: Roland
- Re: formatting floats in a table
- Prev by Date: How to handle exceptions in constructor?
- Next by Date: Re: How to handle exceptions in constructor?
- Previous by thread: How to handle exceptions in constructor?
- Next by thread: Re: formatting floats in a table
- Index(es):
Relevant Pages
|