title: Java Swing: form with text fields
body: <p>I'm doing a form in java.</p>
  
  <p>The idea is:</p>
  
  <p>When an user insert his name and second name he have to press the "submit" button. Now I would like to listen to this action with the submit button but I don't know how to get what the user put in the text fields: "name" and "second name".</p>
  
  <p>I would like to see this data just with the submit button, but i don't know, if it's possible.</p>
  
  <p>Or I would like to know in which way I can see all this data when the user clicks on "submit".</p>
  
  <p>thanks, this is the code.</p>
  
  <pre><code>public class appNegozio extends JFrame {
       private JPanel contentPane;
       private JTextField textField;
       private JTextField textField_1;
  
  /**
   * Launch the application.
   */
       public static void main(String[] args) {
           EventQueue.invokeLater(new Runnable() {
              public void run() {
                try {
                  appNegozio frame = new appNegozio();
                  frame.setVisible(true);
                } catch (Exception e) {
                  e.printStackTrace();
                }
             }
          });
      }
  
  /**
   * Create the frame.
   */
      public appNegozio() {
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setBounds(100, 100, 450, 300);
         contentPane = new JPanel();
         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
         setContentPane(contentPane);
         SpringLayout sl_contentPane = new SpringLayout();
         contentPane.setLayout(sl_contentPane);
  
         textField = new JTextField();
         sl_contentPane.putConstraint(SpringLayout.NORTH, textField, 10,    
                     SpringLayout.NORTH, contentPane);
         sl_contentPane.putConstraint(SpringLayout.WEST, textField, 62, 
                     SpringLayout.WEST, contentPane);
         contentPane.add(textField);
         textField.setColumns(10);
  
         textField_1 = new JTextField();
         sl_contentPane.putConstraint(SpringLayout.NORTH, textField_1, 16, 
                    SpringLayout.SOUTH, textField);
         sl_contentPane.putConstraint(SpringLayout.WEST, textField_1, 0, 
                    SpringLayout.WEST, textField);
         contentPane.add(textField_1);
         textField_1.setColumns(10);
  
        JLabel lblNome = new JLabel("Nome");
        sl_contentPane.putConstraint(SpringLayout.NORTH, lblNome, 10,  
                    SpringLayout.NORTH, contentPane);
        sl_contentPane.putConstraint(SpringLayout.EAST, lblNome, -7, 
                    SpringLayout.WEST, textField);
        contentPane.add(lblNome);
  
        JLabel lblCognome = new JLabel("Cognome");
        sl_contentPane.putConstraint(SpringLayout.NORTH, lblCognome, 0, 
                    SpringLayout.NORTH, textField_1);
        sl_contentPane.putConstraint(SpringLayout.EAST, lblCognome, -6, 
                    SpringLayout.WEST, textField_1);
        contentPane.add(lblCognome);
  
      JButton btnSubmit = new JButton("Submit");
      sl_contentPane.putConstraint(SpringLayout.NORTH, btnSubmit, 24, 
                    SpringLayout.SOUTH, textField_1);
      sl_contentPane.putConstraint(SpringLayout.WEST, btnSubmit, 10, 
                    SpringLayout.WEST, contentPane);
      contentPane.add(btnSubmit);
     }
   }
  </code></pre>