title: Get value of JTextField whose name is stored in a String variable in JAVA
body: <h2><strong>Scenario :</strong></h2>
  
  <pre><code>public class frame1 extends javax.swing.JFrame { 
  
   public void processName(){
   String n1 = "txtName";
   JOptionPane.showMessageDialog(null,"**here i want to show the value from the JTextField using String Variable n1 ,just like we do txtName.getText()**");
   }
  
   private javax.swing.JTextField txtName;
  }
  </code></pre>
  
  <hr>
  
  <p>I know the Question above is weird but the situation which i am in, I must find some other way. please let me know if there's any solution.
  Thanks.</p>
  
  <p><strong>NOTE :</strong> I pasted only the relevant code above. Please assume that I call processName() function on a Button click event.</p>
  
  <p><strong>EDIT :</strong> 
  The Exact Problem is : I have a list of JTextFields that have exactly same name as Database fields.
  Now I want to populate those JTextFields with data from the database using a while loop. And they are many. So I don't want to change the JTextfield names or Database field names.</p>