title: How to retrieve value from JTextField in JTable?
body: <p>Let me break my question in 2 parts.</p>
  
  <ol>
  <li><strong>How to retrieve value from <code>JTextfiled</code> in <code>JTable</code>?</strong></li>
  <li><strong>After all the data how to store in database in one go?</strong></li>
  </ol>
  
  <p>Name and Age should be retrive from <code>JTextfield</code> on <code>jbutton1</code> action and
  by clicking <code>jbutton2</code> all the data of <code>Jtable</code> should be stored in SQL DB.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>package tablefilterdemo;
  
  
  public class Tableinputhroughtextbox extends javax.swing.JFrame {
  
      public Tableinputhroughtextbox() {
          initComponents();
      }
  
      @SuppressWarnings("unchecked")
      // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;                          
      private void initComponents() {
  
          jScrollPane1 = new javax.swing.JScrollPane();
          jTable1 = new javax.swing.JTable();
          jButton1 = new javax.swing.JButton();
          jtfname = new javax.swing.JTextField();
          jtfage = new javax.swing.JTextField();
          jButton2 = new javax.swing.JButton();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          jTable1.setModel(new javax.swing.table.DefaultTableModel(
              new Object [][] {
                  {null, null},
                  {null, null},
                  {null, null},
                  {null, null}
              },
              new String [] {
                  "Name", "Age"
              }
          ));
          jScrollPane1.setViewportView(jTable1);
  
          jButton1.setText("Submit for Table");
  
          jButton2.setText("Submit for SQL");
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(layout.createSequentialGroup()
                          .addGap(29, 29, 29)
                          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                      .addGroup(layout.createSequentialGroup()
                          .addGap(53, 53, 53)
                          .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addGap(46, 46, 46)
                          .addComponent(jtfage, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(jButton1)
                          .addGap(18, 18, 18)
                          .addComponent(jButton2)))
                  .addContainerGap(82, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                  .addContainerGap(92, Short.MAX_VALUE)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(jButton1)
                      .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(jtfage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(jButton2))
                  .addGap(47, 47, 47)
                  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(19, 19, 19))
          );
  
          pack();
      }// &lt;/editor-fold&gt;                        
  
      /**
       * @param args the command line arguments
       */
      public static void main(String args[]) {
          /* Set the Nimbus look and feel */
          //&lt;editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "&gt;
          /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
           * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
           */
          try {
              for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                  if ("Nimbus".equals(info.getName())) {
                      javax.swing.UIManager.setLookAndFeel(info.getClassName());
                      break;
                  }
              }
          } catch (ClassNotFoundException ex) {
              java.util.logging.Logger.getLogger(Tableinputhroughtextbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (InstantiationException ex) {
              java.util.logging.Logger.getLogger(Tableinputhroughtextbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (IllegalAccessException ex) {
              java.util.logging.Logger.getLogger(Tableinputhroughtextbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (javax.swing.UnsupportedLookAndFeelException ex) {
              java.util.logging.Logger.getLogger(Tableinputhroughtextbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          }
          //&lt;/editor-fold&gt;
  
          /* Create and display the form */
          java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                  new Tableinputhroughtextbox().setVisible(true);
              }
          });
      }
  
      // Variables declaration - do not modify                     
      private javax.swing.JButton jButton1;
      private javax.swing.JButton jButton2;
      private javax.swing.JScrollPane jScrollPane1;
      private javax.swing.JTable jTable1;
      private javax.swing.JTextField jtfage;
      private javax.swing.JTextField jtfname;
      // End of variables declaration                   
  }
  </code></pre>