Re: formatting floats in a table
- From: "farseer" <farseer@xxxxxxxxxxxxx>
- Date: 27 Jun 2005 13:53:26 -0700
Thank you for the responses.
1. I would prefer setting a renderer for each column, rather than
assigning renderer for datatypes of that table. This is simply because
of the way i am implementing this. I have an interface named IBehavior
that declares one method, "doBehavior()". My TableCellRender contains
a list of Behaviors. Behaviors are rendering specific actions that
should occur for a given column/cell (i.e. change
foreground/background/border colors depending on the value being
shown). This way i can add multiple behaviors that should be executed
for a given column/cell and simply iterate thru the Behavior list for
that column and call doBheavior. I think i can implment my Formatter
as simply another IBehavior
2. I think you may have answered my question. Currently, i do use a
custom TableModel, and it does indeed override getColumnClass to return
value.getClass. This is how i have gotten sorting to work correctly
(before it sorting was incorrect because everything was being treated
as String).
The following snippet of your code i think answers my question:
protected void setValue(Object value) {
if (value instanceof Number) {
value = formatter.format(value);
}
super.setValue(value);
}
Above, formatter.format(value) will return a String. What you are
saying is that this does not matter for sorting, since my sorting is
being driven off the TableModel and there my getColumnClass method will
return the correct Class Type. Basically, the code above is strictly
for display purposes...and should not affect my sorting, is that
correct?
.
- References:
- formatting floats in a table
- From: farseer
- Re: formatting floats in a table
- From: Roland
- formatting floats in a table
- Prev by Date: Re: How to handle exceptions in constructor?
- Next by Date: Java Pet Store Demo 1.3.2 trouble
- Previous by thread: Re: formatting floats in a table
- Next by thread: remove redundency in list of pairs
- Index(es):
Relevant Pages
|