title: Document listener brings a null pointer exception
body: <p>I use a document listener and it brings me a null pointer exception . How could I stop this exception . I use this for search some content of a table. With using this I could search relevant content . Also this brings me a null pointer exception . </p>
  
  <p>These are the steps,</p>
  
  <p>In the beginning, </p>
  
  <pre><code>Vector originalTableModel;
  DocumentListener documentListener;
  </code></pre>
  
  <p>In the counstructor,</p>
  
  <pre><code>originalTableModel = (Vector) ((DefaultTableModel) list_table.getModel()).getDataVector().clone();
  //add document listener to jtextfield to search contents as soon as something typed on it
  addDocumentListener();
  </code></pre>
  
  <p>My documentlistener method,</p>
  
  <pre><code>private void addDocumentListener(){
     documentListener = new DocumentListener(){
        public void changedUpdate(DocumentEvent documentEvent){
             search();
        }
  
        public void insertUpdate(DocumentEvent documentEvent){
             search();
        }
  
        public void removeUpdate(DocumentEvent documentEvent){
             search();
        }
  
        private void search(){
             searchTableContents(search_field.getText());
        }
  
     };
  }
  </code></pre>
  
  <p>My searching Method,</p>
  
  <pre><code>public void searchTableContents(String searchString)
  {
      DefaultTableModel currtableModel = (DefaultTableModel) list_table.getModel();
      //To empty the table before search
      currtableModel.setRowCount(0);
      //To search for contents from original table content
      for (Object rows : originalTableModel)
      {
          Vector rowVector = (Vector) rows;
          for (Object column : rowVector)
          {
  
                  if **(column.toString().toLowerCase().contains(searchString.toLowerCase())**)
                  {
  
                      //content found so adding to table
                      currtableModel.addRow(rowVector);
                      break;
                  }
  
  
          }
      }
  }
  </code></pre>
  
  <p>This is the place where I called this method,</p>
  
  <pre><code>private void search_fieldKeyReleased(java.awt.event.KeyEvent evt)                                                      
  {                                                          
      // TODO add your handling code here:
      searchTableContents(search_field.getText());
  }
  </code></pre>
  
  <p>I bold the point where I got this null pointer exception.</p>
  
  <p>Have any ideas ?</p>