How to get the stored object from JTable
<p>I have a JTable in which I can add users with several attributes like age, name, etc. This works and the users are added to my arraylist and JTable.
Now what I want is when I choose the JTable row, to be able to get the object stored in the user's arrayList so that I can modify or delete them.</p>

<p>Here is the example of my code when I add users to the JTable:</p>

<pre><code>private void jButtonAddAUserActionPerformed(java.awt.event.ActionEvent evt) {                                                
   User obj=new User();
   obj.setName(jTextFieldName.getText());
   obj.setAdress(jTextFieldAdress.getText());
   obj.setNumCC(Integer.parseInt(jTextFieldNumCC.getText()));
   obj.setTele(Integer.parseInt(jTextFieldTele.getText()));
   obj.setUserName(jTextFieldUserName.getText());
   obj.setPassword(jTextFieldPassword.getText());

   DefaultTableModel model=(DefaultTableModel) jTableUsers.getModel();
   model.addRow(new Object[]{
       jTextFieldName.getText(),
       jTextFieldAdress.getText(),
       jTextFieldTele.getText(),
       jTextFieldNumCC.getText(),
       obj.isAdmin
   });

   usersList.add(obj);
   JOptionPane.showMessageDialog(null,"Data inserted correctly.");
   jTextFieldName.setText("");
   jTextFieldAdress.setText("");
   jTextFieldNumCC.setText("");
   jTextFieldTele.setText("");
   jTextFieldPassword.setText("");
   jTextFieldUserName.setText("");
}   
</code></pre>

<p>Edit:
Here is the code for removing users already working:</p>

<p>private void jButtonRemoverActionPerformed(java.awt.event.ActionEvent evt) {                                               </p>

<pre><code>    DefaultTableModel model = (DefaultTableModel) jTableInvestidores.getModel();

    User u = userList.get(jTableUsers.getSelectedRow()); 
    userList.remove(u);
    model.removeRow(jTableUsers.getSelectedRow());
    JOptionPane.showMessageDialog(null,"Data removed.");

}  
</code></pre>

<p>And here is the code for updating user that is still not working, im trying to update it from the jTextFields:</p>

<pre><code>private void jButtonUpdateActionPerformed(java.awt.event.ActionEvent evt) {                                                  

    DefaultTableModel model = (DefaultTableModel) jTableUsers.getModel();
    userList.get(jTableUsers.getSelectedRow());
    model.setValueAt(jTextFieldName.getText(), jTableUsers.getSelectedRow(),0);
    model.setValueAt(jTextFieldAdress.getText(), jTableUsers.getSelectedRow(),1);
    model.setValueAt(jTextFieldPhone.getText(), jTableUsers.getSelectedRow(),2);
    model.setValueAt(jTextFieldNumCC.getText(), jTableUsers.getSelectedRow(),3);
    User u =userList.get(jTableUsers.getSelectedRow());

    JOptionPane.showMessageDialog(null,"Data updated.");

}   
</code></pre>

<p>Can anyone please give me some help on this? Thanks!</p>