title: error in setModel builder
body: <p>I am implementing my own model from the TableModel interface. My problem is in the builder of my model. I pass as arguments an Object[][] like datas readed from the database and Object[] like headers readed from the database too.</p>
  
  <p>In the tableModel interface i have an ArrayList where i keep the datas readed from DB.</p>
  
  <p>How can i copy my Object[][] of two dimensions to my ArrayList.</p>
  
  <p>In the following lines i show my code where you can see what i am doing.</p>
  
  <pre><code>public class MiModelo implements TableModel{
  
  private ArrayList&lt;TableModelListener&gt; listeners=new ArrayList&lt;TableModelListener&gt;();
  
  private ArrayList&lt;Object[]&gt; datos=new ArrayList&lt;Object[]&gt;();
  
  private ArrayList&lt;String&gt; titulos=new ArrayList&lt;String&gt;();
  
  public MiModelo(Object[][] obj, Object[] head){
      Object[] registro;
      for (int i=0;i&lt;obj.length;i++){
          registro=new Object[obj[i].length];
          for (int k=0;k&lt;obj[i].length;k++){
              registro[k]=obj[i][k];
          }
          System.out.println(registro[0]+", "+registro[1]+", "+registro[2]+", "+registro[3]);
          datos.add(registro);
      }
  
  
      for (int i1=0;i1&lt;head.length;i1++)
          titulos.add((String) head[i1]);
  }
  </code></pre>
  
  <p>For some reasson this builder doesn't work. In Eclipse it shows the following error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at javax.swing.JTable.prepareRenderer(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
  at javax.swing.plaf.ComponentUI.update(Unknown Source)
  at javax.swing.JComponent.paintComponent(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JViewport.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JLayeredPane.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paintToOffscreen(Unknown Source)
  at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
  at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
  at javax.swing.RepaintManager.paint(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
  at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
  at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
  at java.awt.Container.paint(Unknown Source)
  at java.awt.Window.paint(Unknown Source)
  at javax.swing.RepaintManager$3.run(Unknown Source)
  at javax.swing.RepaintManager$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.access$1000(Unknown Source)
  at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
  at java.awt.event.InvocationEvent.dispatch(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$200(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at javax.swing.JTable.prepareRenderer(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
  at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
  at javax.swing.plaf.ComponentUI.update(Unknown Source)
  at javax.swing.JComponent.paintComponent(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JViewport.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at javax.swing.JLayeredPane.paint(Unknown Source)
  at javax.swing.JComponent.paintChildren(Unknown Source)
  at javax.swing.JComponent.paintToOffscreen(Unknown Source)
  at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
  at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
  at javax.swing.RepaintManager.paint(Unknown Source)
  at javax.swing.JComponent.paint(Unknown Source)
  at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
  at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
  at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
  at java.awt.Container.paint(Unknown Source)
  at java.awt.Window.paint(Unknown Source)
  at javax.swing.RepaintManager$3.run(Unknown Source)
  at javax.swing.RepaintManager$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
  at javax.swing.RepaintManager.access$1000(Unknown Source)
  at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
  at java.awt.event.InvocationEvent.dispatch(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$200(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>In the code, as you can see, i have writen a System.out.println, to see if it is Reading from database, and aparently it is ok.</p>
  
  <p>Thank you in advance.</p>