title: "AWT-EventQueue-0" java.lang.NullPointerException
body: <p>I'm getting a ''Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException'' in my code. I have no idea why and where this exception occurs. The compilation works fine but sometimes I get this error at runtime. Can I have some help here? The full error message is this:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2115)
  at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2016)
  at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1812)
  at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
  at javax.swing.JComponent.paintComponent(JComponent.java:778)
  at javax.swing.JComponent.paint(JComponent.java:1054)
  at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
  at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
  at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
  at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
  at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
  at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770)
  at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
  at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
  at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
  at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
  at java.awt.EventQueue.access$000(EventQueue.java:101)
  at java.awt.EventQueue$3.run(EventQueue.java:666)
  at java.awt.EventQueue$3.run(EventQueue.java:664)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
  at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
  </code></pre>
  
  <p>part of my code:</p>
  
  <pre><code>class UserAgentGui extends JFrame implements ActionListener, ListSelectionListener, CinemaVocabulary {
  
  private JTable movieTable;
  
  public UserAgentGui(UserAgent a) {
  // -----------------------------------   Constructor
  
      Object obj[][] = new Object[0][columnNames.length];
      TableModel model = new TableDataModel(obj, columnNames);
      movieTable = new JTable(model);
  movieTable.setFillsViewportHeight(true);
      movieTable.setPreferredScrollableViewportSize(new Dimension(320,100));
      movieTable.setFont(new Font("Arial", Font.PLAIN, 11));
  }
  
  void displayMovies(java.util.leap.List list) {
  // -------------------------------------------
      String s = "";
  
      if (menu.getSelectedItem().equals(actions[1])){//  &lt;-- This is a list of movies
          s = "Movie-databse is presented";
          data = new Object[list.size()][columnNames.length];
          for (int i = 0; i &lt; list.size(); i++) {
              Movie movie = (Movie)list.get(i);
              data[i][0] = movie.getTitle();
              data[i][1] = movie.getYear();
              data[i][2] = movie.getKind();
              data[i][3] = 0.0;
          }
      TableDataModel model = (TableDataModel)movieTable.getModel();
      model.setData(data);
      movieTable.setModel(model);
      movieTable.updateUI();
      }
      else {
          s = "Score Movies";
      }
      msg_text.setText(s);    
  }
  
  // =========================== External class ============================//
  
  /* TableDataModel:
  *  --------------
  *  External class for the definition of the tables data model, used to
  *  control the display of data within the different tables
  **/
  class TableDataModel extends AbstractTableModel {
  // ----------------------------------------------
  
     private String[] columns;
     private Object[][] data;
  
     public TableDataModel(Object[][] data, String[] columns) {
     // ----------------------------------------------------------  Constructor
        this.data = data;
        this.columns = columns;
     }
  
     public int getColumnCount() {
     // -----------------------------  Return the number of columns in the table
        return columns.length;
     }
  
     public int getRowCount() {
     // --------------------------  Return the number of rows in the table
        return data.length;
     }
  
     public String getColumnName(int col) {
     // --------------------------------------  Return the name of a column
        return columns[col];
     }
  
    public boolean isCellEditable(int row, int col) {
     // -------------------------------------------------
              if (col == 3) {
                  return true;
             } else {
                 return false;
              }
     }
  
     public Object getValueAt(int row, int col) {
     // --------------------------------------------  Return the value at a specific
  //                                               row and column
        if ( data.length == 0 ) return null;
           return data[row][col];
      }
  
     public Class getColumnClass(int col) {
     // --------------------------------------  Return the class of the values held
     //                                         by a column
        Object o = getValueAt(0, col);
        if (o == null) return columns[col].getClass();
           return getValueAt(0, col).getClass();
     } 
  
     public void setValueAt(Object value, int row, int col){
      // -------------------------------------------------------  Set the value at a        specific
     //                                                          row and column
        data[row][col] = value;
    }
  
     public void setData(Object[][] data){
     // -------------------------------------  Update the entire data in the table
         this.data = data;
     }
  
     Object[][] getData(){
     // ---------------------  Return the entire data of the table
         return data;
     }
  }// end TableDataModel
  }
  </code></pre>