Re: Editor / Renderer: data flow



"Denis" <denis.mazzucato@xxxxxxxxx> wrote in news:1140769944.254545.278210
@u72g2000cwu.googlegroups.com:

Thanks!
My error was on the model.
I didn't implement method setValueAt(Object value, Object node, int
column) and so the model didn't change!

Ok. Now: I need to implement formula into the table referring to other
cells, and the table change dinamically.

I thought to add a custom-made listener to cells containing formula and
when a cell change I send to the listener an event like "dataChenged".
Is the correct approach?

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
.