title: Putting the contents of a JTextField into a Variable - Java & Swing
body: <p>So i creating a little java app and am just wondering how i can get the contents of a JTextField and then assign the value into a String variable, I thought below would work:</p>
  
  <pre><code>JTextField txt_cust_Name = new JTextField();
  String cust_Name;
  txt_cust_Name.addActionListener(new ActionListener() 
  {
      public void actionPerformed(ActionEvent e) 
      {
           cust_Name = txt_cust_Name.getText();
      }
  });
  </code></pre>
  
  <p>Now i thought that this would send the value of the JtextField into the String Cust_Name.</p>
  
  <p>Anyone have any ideas to do this?</p>
  
  <p>Cheers.</p>