Interface BasicTableModel

All Superinterfaces:
TableModel

public interface BasicTableModel extends TableModel
This interface defines a basic table model which can be used to create a table model using lambda expressions. Implementations of this are typically created declarative like so:

      UI.table( conf -> conf
          .colNames("A", "B")
          .colCount(()->2)
          .rowCount(()->3)
          .getsEntryAt((int row, int col)->
              vm.getDataAt(row, col)
          )
      )
  
Note that TableData is the recommended way of modelling a table in SwingTree. It is a single immutable value describing the whole table (cells, column names, column classes, cell order and editability), which you hold in a Var property and bind through UIFactoryMethods.table(sprouts.Var):

      Var<TableData> data = Var.of(
              TableData.of(UI.CellOrder.ROW_MAJOR, "A", "B")
                  .addRow(1, 2)
          );

      UI.table(data);
  
A table bound like that updates itself whenever the property changes (so there is no updateOn(..) to remember), it is thread safe by construction, and it syncs row changes to the JTable incrementally instead of rebuilding it. The lambda based model below, by contrast, is read live, which is why SwingTree has to copy the whole table on every refresh under the EventProcessor.DECOUPLED protocol.

Note that an implementation of this interface is merely a description of where the table data lives, it is not the model which the JTable ends up talking to. SwingTree always wraps it in a thread safe model of its own, which reads through the methods declared here and, under the EventProcessor.DECOUPLED protocol, keeps a UI thread owned snapshot of them so that the AWT Event Dispatch Thread never reads your application thread owned state while it paints. This is also why you should not expect JTable.getModel() to return the very object you passed to withModel(..).