title: Trouble understanding how to use table models and observables together
body: <p>I have some fairly complicated data and at the moment resides in hash tables that point to other classes that also contain hash tables because there are one-many relationships within the data I am trying to preserve.</p>
  
  <p>On the other side of the world, I have a table that works quite nicely, with the exception that it does not have any connection to my data model. It has it's own table model. I create it in a very simple manner-</p>
  
  <pre><code>Object[][] tableData = new Object[4][ tableHeaders.length ];
  modelTablet  = new TabletTableModel(tableData, tableHeaders );
  </code></pre>
  
  <p>my tablet data model is very simple,</p>
  
  <pre><code>class TabletTableModel extends DefaultTableModel {
  
     public TabletTableModel(Object rowData[][], Object columnNames[]) {
        super(rowData, columnNames);
     }
  
     @Override
     public Class getColumnClass(int col) {
          if (col == 0) {
             return String.class;
          } else {
             return Double.class;
          }
     }
  
     @Override
     public boolean isCellEditable(int row, int col)
     {
        if (col == 0 || col == activeColumn)
           return true;
        else
           return false;
     }
  }
  </code></pre>
  
  <p>which suites me, since I also have to do things like add and remove rows, which with this simple data model, most of the work is done for me.</p>
  
  <pre><code>class AddRowActionListener implements ActionListener {
      public void actionPerformed(ActionEvent event) {
      DefaultTableModel model = (DefaultTableModel)tableTablet.getModel();
      model.addRow(new Object[3]);
      System.out.println(Arrays.deepToString(tableData));
      }
  }
  </code></pre>
  
  <p>I've also implemented a mouse listener and a cell renderer so that when I click on the header of a column it becomes active and the cells in the adjoining column are repainted in another color to indicate they are no longer editable.</p>
  
  <p>So far so good, but for my interface, I have a second table that summarizes the results of the first table. It's just three rows, no header. I think I may have done more work than I needed to when I made it.</p>
  
  <pre><code>modelSummary = new SummaryTableModel(1, tableHeaders.length);
  tableSummary = new JTable(modelSummary);
  
  class SummaryTableModel extends DefaultTableModel {
  
     public SummaryTableModel(int rows, int columns) {
        super(rows, columns);
     }
  
     @Override
     public Class getColumnClass(int col) {
          if (col == 0) {
             return String.class;
          } else {
             return Double.class;
          }
  
     @Override
     public boolean isCellEditable(int row, int col)
     {
        if (col == 1 &amp;&amp; activeColumn == 2)
           return true;
        else
           return false;
     }
  }
  </code></pre>
  
  <p>So that gives me a nice set of tables, they recolor like they are supposed to, they limit data to valid values and format it properly (with my renderers I did not list).</p>
  
  <p>But here is what is supposed to happen- the user enters a value in column 1 of table 1, I then need to sum over all the values in column 1, out that value in column 1 of table 2 and then recalculate all the values in column 2 of table 1 based on this new value.</p>
  
  <p>Conversely, if column 2 is the active column and the user changes a value in column 2 of table 1, then I need to get the value of column 1 in table 2 and use it to recalculate all the values for column 1 in table 1 and also sum the values of column 2 and place them in column 2 of table 2. With a caveat that the user can't enter a new value such that the sum of the numbers in column 2 exceeds 100.</p>
  
  <p>Table 2 can also be edited, which would require calculating all the values in table 1.</p>
  
  <p>So... to me that seems like I should have an observable and I should register my tables as both observers and as controllers for the observable. So I can write an observable, but I also still have my two table data models. I have been reading a lot, but all the examples I have found show in an observable used with something simple, like a text field or table models, but not using the Observable class. The other problem is that I am not sure how to do most of the cool things (like adding rows or checking types) that the default model happily does for me by default.</p>
  
  <p>Before I add a whole new dimension of complexity to my project- could someone give me some pointers? Is it easy to mix data models that pretty much have no conception of rows or columns with table data models in some way that doesn't require writing all the default table model operations over again? The whole process seems unbelievably complex to me at the moment. I desparatetly need some clear explanation of how this should work.</p>