title: How to stop JTable TableModelListener from firing or listening when specific column on table changed
body: <p>I have created a <code>TableModelListener</code> which listens to specific column. Specifically, columns <strong>2,3,4,5</strong>. Such that when any column from <strong>2-5</strong> has value or <code>not null</code>, it will take and add the values store to a <code>BigDecimal</code> value to get the <strong>sum</strong>. After that, I need to set the value of the 6th column to the sum of values of columns <strong>2-5</strong>. So I thought I can simply collect the values then if it encounters column <strong>6</strong>, it will set the sum.</p>
  
  <p>Here's the code.</p>
  
  <pre><code>@Override
      public void tableChanged(TableModelEvent e) {
          DefaultTableModel tableModel = (DefaultTableModel) e.getSource();
          if (tableModel.getRowCount() &gt; 0) {
              for (int row = 0; row &lt; tableModel.getRowCount(); row++) {
                  BigDecimal sum = new BigDecimal(BigInteger.ZERO).setScale(2,RoundingMode.HALF_UP);
                  for (int col = 0; col &lt; tableModel.getColumnCount(); col++) {
                      if (col == 2 || col == 3 || col == 4 || col == 5) {
                          if (tableModel.getValueAt(row, col) != null) {
                              sum = sum.add(new BigDecimal(Double.parseDouble(tableModel.getValueAt(row, col).toString())));
                          }
                      } 
                  }
                  JOptionPane.showMessageDialog(null,"Sum: "+sum);
                  tableModel.setValueAt(sum, row, 6);
              }
          }
      }
  </code></pre>
  
  <p>So what happens is I get an infinite <code>JOptionPane Dialog</code> with the value of sum.
  I researched online and thought that maybe after editing I could terminate the listener by adding <code>view.getMyJTable().putClientProperty("terminateEditOnFocusLost", true);</code></p>
  
  <p>Didn't help. I basically just want to be able to get the sum of columns 2-5 whether or not the columns has value that is why I initialized the <code>BigDecimal</code> to <code>ZERO</code></p>
  
  <p>It appears to be listening table model changes even on 6th column. I don't know how to select specific columns where the <code>tablechanged</code> will apply.</p>
  
  <p>Thanks.</p>