title: Java swing save several text field to a object
body: <p>Im quite new to java swing but im creating a stock management program, i have now my window registration form were the user can insert, name, adress, username, password, etc, and i have a button below to save all data.
  I want to e able to press the save button and all the data be saved to a new userObject, my problem is how to associate each textfield data so they can be saved to new object in save button.
  Can anyone give me some pointers on how to do this?</p>
  
  <p>Thanks!</p>
  
  <p>I tried the code this way:</p>
  
  <p>private void ButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {                                                   </p>
  
  <pre><code>   User obj=new User();
     String userName = UserTextFieldName.getText();
     String userAdress = UserTextFieldAdress.getText();
     String userCitizenID = UserTextFieldCitizenID.getInteger();
     obj.setName(userName);
     obj.setAdress(userAdress);
     obj.setCitizenID(userCitizenID);
  
     usersArrayList.add(obj);
  </code></pre>
  
  <p>//this is were i would give a save correctly message and dispose the registration window.</p>
  
  <p>Is this a good alternative method?i could not make it working the other way with the ActionListener...</p>