"Denis" <denis.mazzucato@libero.it> wrote in news:1140769944.254545.278210
@u72g2000cwu.googlegroups.com:
> Thanks!
> My error was on the model.
[quoted text clipped - 9 lines]
>
> DM
This is a possibility, however I think you can get the same effect a lot
easier by using a TableModelListener, or a subclass of it. You don't need
to define your own event & listener, and you don't need to add a listener
to each cell - if a lot of cells contain formulas, or if the user can add a
formula to any and all cells, this will be a lot more efficient.
Register a TableModelListener on the TableModel, and if a tableChanged
event is raised, check if any formulas depend on the changed cell(s), and
update as needed. Checking which, if any, formulas depend on the changed
cell(s) can probably be optimised by subclassing TableModelListener, or
maybe a separate class can keep track of this info, depending on what best
fits your design.
Zero
Denis - 27 Feb 2006 08:01 GMT
>Register a TableModelListener on the TableModel, and if a tableChanged
>event is raised, check if any formulas depend on the changed cell(s), and
>update as needed. Checking which, if any, formulas depend on the changed
>cell(s) can probably be optimised by subclassing TableModelListener, or
>maybe a separate class can keep track of this info, depending on what best
>fits your design.
But in this case I have to save all the information about any formula
on the model, right?
When an event tell me a cell is changed how can I find wich formula
need to be updated?
In my solution every cell involved in a formula have a Vector of
listeners (cells containing formula that require the current cell) to
inform. When a cell is updated, a message is send to all formulas to be
updated.
Is there an open source java grid to study?
Thanks.
DM