« Return to Thread: Add a 'Total's' row to a FunctionList

Re: Add a 'Total's' row to a FunctionList

by Gerrit Cap :: Rate this Message:

Reply to Author | View in Thread

I don't think there is a generic solution for this. But I've created in
the past a TotalizingList which is very similar to the FunctionList.

In short this TotalizingList
    1) maintains a copy of the original source list as an extension of
TransformingList
    2) creates an extra object "the total"
    3) size() == source.size() +1, and also adjust get(int) ...
    4) defines an interface Totalizer which defines an addToTotal method
and removeFromTotal method called when objects are inserted or deleted
(update == delete of old + insert of new)
    5) on listChanges -> delegate to the totalizer function and
broadcast list changes as source list changes + last row also updated.


Gerrit

Dan MacLeod wrote:
> I have a FunctionList that creates new Objects based on a GroupingList, and a
> JTable that displays the results. I'd like to add a 'Total' row at the
> bottom of the table that adds up the values in each column, is there a way
> to do this?
>  

--
-------------------- Marble Consulting ----------------------
Gerrit Cap                      http://www.marble.be/
OO Solutions Engineer           mailto:Gerrit.Cap@...
Marble Consulting               gsm : +32 475 72.94.36
Vinkenbosstraat 13              tel : +32 16 89.50.55
B-3001 Heverlee                 fax : +32 16 89.50.58    



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Add a 'Total's' row to a FunctionList