title: Java Jtable error with setting a value to a column after listener runs
body: <p>I am working on the TableModelListener for a JTable. Now the jtable can get the value fine. but when it comes down to setting the value of the last column of the selected row. It gets wonky, not sure what the error is it just hangs up. Not seeing any errors on netbeans so not sure what to think. Because of this I am not even sure if the if statements work at all in terms of setting values. Should I be using or doing something else for this to happen ?
  Update: It does appear to be an infinite loop. edited the code to a suggestion to check for Update table events but still having the same problem.
  Here is the code below:</p>
  
  <pre><code>public  class MyListener implements TableModelListener {
  
      @Override
      public void tableChanged(TableModelEvent tme) { 
  
       if (tme.getType() == TableModelEvent.UPDATE)
          {
             int rowcount = jDetailSubmitTable.getSelectedRow();
  
             // Initial return when table is starting to be filled.
          if(rowcount == -1 )
          {
              return;
          }
  
          int com = tme.getColumn();
  
          // Number being Validated.
          if(jDetailSubmitTable.getModel().getValueAt(rowcount, com).toString().trim().isEmpty())
          {
              JOptionPane.showMessageDialog(null, "Invaid Number selected.");
              jDetailSubmitTable.getModel().setValueAt("0", rowcount, com);
              return;
          }
          try
          {
            Double.parseDouble(jDetailSubmitTable.getModel().getValueAt(rowcount, com).toString().trim());
          }
          catch(NumberFormatException e)
          {
              JOptionPane.showMessageDialog(null, "Invaid Number selected.");
              jDetailSubmitTable.getModel().setValueAt("0", rowcount, com);
              return;
          }
  
  
          // Adjusted amount is calculated below.
  
          double nur = Double.parseDouble(jDetailSubmitTable.getModel().getValueAt(rowcount, 9).toString().trim());
          double our = Double.parseDouble(jDetailSubmitTable.getModel().getValueAt(rowcount, 8).toString().trim());
          double diff = nur - our;
          double nunits = Double.parseDouble(jDetailSubmitTable.getModel().getValueAt(rowcount, 11).toString().trim());
          double ans = diff * nunits;
  
          jDetailSubmitTable.getModel().setValueAt(ans, rowcount, 12);  
      }
   }
  </code></pre>
  
  <p>}</p>