I am currently in a Java course. We are writing an application to store an inputted name and phone number in an arraylist. When an add contact button is pressed it should return the data into two separate JTextFields which is stored in a class and can be scrolled through. I am having trouble getting the data to return to the Textfields. Thanks
private int position = 0;
private void addContactJButtonActionPerformed(java.awt.event.ActionEvent evt) {
setContact();
newContact = new Contact(nameJTextField.getText(),
Integer.parseInt(numberJTextField.getText()));
ContactsArrayList.add(newContact);
position = ContactsArrayList.size() - 1;
loadContact();
}
public void setContact()
{
newContact.setName(nameJTextField.getText());
newContact.setNumber(Integer.parseInt(numberJTextField.getText()));
}
public void loadContact()
{
newContact = (Contact) ContactsArrayList.get(position);
storedNameJTextField.setText(newContact.getName());
storedNumberJTextField.setText(String.valueOf(newContact.getNumber()));
}