title: Update JTable after clicking a JButton
body: <p>When i click the Button "Sale", the Table must show in the first row, which item i sold, and how much was it. But when i click a second time, it deletes de last row, and creates a new table. How can i create a new row, with the new Data? 
  This is my code:</p>
  
  <pre><code>if (e.getSource()==sale)
      {
          int tempcod=0,tempcant=0; //tempcod is the code of the product,
         temocant is the number of products sold
  
      final DefaultTableModel model = new DefaultTableModel();
  
          model.addColumn("Product");
          model.addColumn("Price");
  
          try
          {
          tempcod=Integer.parseInt(cod.getText());
          tempcant=Integer.parseInt(quantity.getText());
          }
          catch(NumberFormatException a)
          {
              JOptionPane.showMessageDialog(null, "Invalid Number");
          }
  
          for (int j=0;j&lt;nulo; j++) //nulo is the number of items at sale
          {
  
              if (tempcod==codigo[j]) //id the code i wrote exist in 
                                        the list of products
              {
                  for (int k=0; k&lt;nulo; k++)
                  {
                      if (tempcod==ventaActual[0][k])
                      {
                          ventaActual[1][k]+=tempcant;
                      }
                      else
                      {
                      ventaActual[0][k]=tempcod;
                      ventaActual[1][k]=tempcant;
                      }
                  }
  
                  model.insertRow(model.getRowCount(), new Object[]{item[j],price[j]*tempcant});//this line creates the row of the table.
            //item[] is the name of the item, price[] is the price of the item
                  JTable Lista= new JTable(model);
                  lista1=new JScrollPane(Lista);
                  lista1.setBounds(170,150,200,200);
                  lista1.setEnabled(false);
                  lista1.setVisible(true);
                  this.add(lista1);
  
                  a+=(tempcant*precio[j]);
                  String b=Integer.toString(a);
                  tot.setText(b);
                  ventaInforme=ventaActual;
              }
              else
              {
                  cod.setText(null);
                  cantidad_n.setText(null);
              }
          }
      }
  </code></pre>