title: JTreeTable updating
body: <p>I'm trying to use the example taken from the <a href="http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html" rel="nofollow">http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html</a>, in which I've substituted the filesystem model with my model.</p>
  
  <p>I initially create a model, I display it in the <code>JTreeTable</code>, but now I'd like to update my model and then the <code>JTreeTable</code> (for example I want to add a node at the tree, modify a node, remove a node, etc.).</p>
  
  <p>I don't know how I can do it. I can't see method that allow me to do what I want, I only see some method like <code>treeNodesChanged</code>, <code>treeNodesInserted</code>, etc.,  but probably I miss something in the global logic of this <code>JTreeTable</code> component.</p>
  
  <p>Besides I'm not sure that I correctly create the model, because in various example I've seen people call various method over a "model" object (<code>model.insertNodeInto</code>, <code>model.reload</code>), inspite of I haven't a model object..In the example above, is simply called the abstract class <code>AbstractTreeTableModel</code> which implements <code>TreeTableModel</code>.. </p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>public class TableModel extends AbstractTreeTableModel 
                           implements TreeTableModel {
   static protected String[]  cNames = {"TrackNumber", "MWRTN", "LSRTN", "RFTN","TrackStatus","Prova","Prova2"};
      // Types of the columns.
   static protected Class[]  cTypes = {TreeTableModel.class,Integer.class, Integer.class, Integer.class, Integer.class,String.class,String.class};
  
   private ArrayList&lt;Object&gt; data=new ArrayList&lt;Object&gt;();
       public void insertNode(Object node)
       {    this.data.add(node);    super.setRoot(data.get(0));}
  </code></pre>
  
  <p>In my main class I add objects to my model in this way:</p>
  
  <pre><code>...
  model =new TableModel();
  model.insertNode(threatList.get(i)); //inserting the root node
  model.addChild(threatList.get(i),threatList.get(j)); // inserting the child
  ...
  </code></pre>
  
  <p>Then I pass the model to my <code>JTreeTable</code> and add it to my frame:</p>
  
  <pre><code>treeTable = new JTreeTable(model);
  JScrollPane scroll=new JScrollPane(treeTable);
  scroll.setAutoscrolls(false);
  scroll.setPreferredSize(new Dimension(1000,80));
  frame.add(scroll);
  </code></pre>
  
  <p>And this is the JTreeTable class:</p>
  
  <pre><code>public class JTreeTable extends JTable {
  protected TreeTableCellRenderer tree;
  
  public JTreeTable(TreeTableModel treeTableModel) {
  super();
  
  // Create the tree. It will be used as a renderer and editor. 
  tree = new TreeTableCellRenderer(treeTableModel); 
  
  // Install a tableModel representing the visible rows in the tree. 
  super.setModel(new TreeTableModelAdapter(treeTableModel, tree));
  
  // Force the JTable and JTree to share their row selection models. 
  tree.setSelectionModel(new DefaultTreeSelectionModel() { 
      // Extend the implementation of the constructor, as if: 
   /* public this() */ {
      setSelectionModel(listSelectionModel); 
      } 
  }); 
  // Make the tree and table row heights the same. 
  tree.setRowHeight(getRowHeight());
  
  // Install the tree editor renderer and editor. 
  setDefaultRenderer(TreeTableModel.class, tree); 
  setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());  
  
  setShowGrid(false);
  setIntercellSpacing(new Dimension(0, 0)); 
  setPreferredSize(new Dimension(60,60));
  }
  
  /* Workaround for BasicTableUI anomaly. Make sure the UI never tries to 
   * paint the editor. The UI currently uses different techniques to 
   * paint the renderers and editors and overriding setBounds() below 
   * is not the right thing to do for an editor. Returning -1 for the 
   * editing row in this case, ensures the editor is never painted. 
   */
  public int getEditingRow() {
      return (getColumnClass(editingColumn) == TreeTableModel.class) ? -1 : editingRow;  
  }
  
  // 
  // The renderer used to display the tree nodes, a JTree.  
  //
  
  public class TreeTableCellRenderer extends JTree implements TableCellRenderer {
  
  protected int visibleRow;
  
  public TreeTableCellRenderer(TreeModel model) { 
      super(model); 
  }
  
  public void setBounds(int x, int y, int w, int h) {
      super.setBounds(x, 0, w, JTreeTable.this.getHeight());
  }
  
  public void paint(Graphics g) {
      g.translate(0, -visibleRow * getRowHeight());
      super.paint(g);
  }
  
  public Component getTableCellRendererComponent(JTable table,
                             Object value,
                             boolean isSelected,
                             boolean hasFocus,
                             int row, int column) {
      if(isSelected)
             setBackground(table.getSelectionBackground());
      else
             setBackground(table.getBackground());
  
      visibleRow = row;
      return this;
      }
   }
  
   // 
   // The editor used to interact with tree nodes, a JTree.  
   //
  
  public class TreeTableCellEditor extends AbstractCellEditor implements TableCellEditor {
      public Component getTableCellEditorComponent(JTable table, Object value,
                               boolean isSelected, int r, int c) {
          return tree;
      }
  
      @Override
      public Object getCellEditorValue() {
          // TODO Auto-generated method stub
          return null;
      }
  }
  </code></pre>
  
  <p>What I would is to fire an event after adding(or modifying, or removing) a child.</p>