I\'m making an address book and I need to cycle through my contacts. The contacts are imported from file and are read into the JTextField
s as so:
name
In your importContacts()
method
you do :
txtName.setText(Name.get(0));
txtPhone.setText(Phone.get(0));
txtMobile.setText(Mobile.get(0));
txtAddress.setText(Address.get(0));
instead of .get(0)
I think it should be .get(index)
according to your code
--Edit--
or to avoid re-importing your contact here what your previous() method should be :
public void Previous()
{
if (index > 0)
{
index--;
}
txtName.setText(Name.get(index));
txtPhone.setText(Phone.get(index));
txtMobile.setText(Mobile.get(index));
txtAddress.setText(Address.get(index));
}
public void Next()
{
if(index < temp.size() - 1){
index++;
}
txtName.setText(Name.get(index));
txtPhone.setText(Phone.get(index));
txtMobile.setText(Mobile.get(index));
txtAddress.setText(Address.get(index));
}
-Final edit, code source availabe at pastebin